[PATCH] LDAP suffix behaviour

Tim Potter tpot at samba.org
Thu Sep 11 06:10:04 GMT 2003


According to the manual page, the various ldap suffixes (user, group,
machine and idmap) take the value of the top level 'ldap suffix' 
parameter if not defined.  In the actual code, the value of the ldap
suffix is appended to the various subsuffixes.

This produces some bizzare swat behaviour as setting the
value of the ldap suffix changes the value of the subsuffixes 
after you hit Submit and you end up with multiple copies of the
ldap suffix appended to the subsuffix values.

Anyway, this patch fixes things although it does change current
behaviour however it changes it to what the documentation says.


Tim.
-------------- next part --------------
Index: param/loadparm.c
===================================================================
RCS file: /data/cvs/samba/source/param/loadparm.c,v
retrieving revision 1.397.2.100
diff -u -r1.397.2.100 loadparm.c
--- param/loadparm.c	10 Sep 2003 00:39:34 -0000	1.397.2.100
+++ param/loadparm.c	11 Sep 2003 06:07:17 -0000
@@ -563,9 +563,6 @@
 static BOOL handle_netbios_scope( const char *pszParmValue, char **ptr );
 static BOOL handle_charset( const char *pszParmValue, char **ptr );
 
-static BOOL handle_ldap_suffix ( const char *pszParmValue, char **ptr );
-static BOOL handle_ldap_sub_suffix ( const char *pszParmValue, char **ptr );
-
 static BOOL handle_acl_compatibility(const char *pszParmValue, char **ptr);
 
 static void set_server_role(void);
@@ -1061,11 +1058,11 @@
 	{"ldap server", P_STRING, P_GLOBAL, &Globals.szLdapServer, NULL, NULL, FLAG_ADVANCED}, 
 	{"ldap port", P_INTEGER, P_GLOBAL, &Globals.ldap_port, NULL, NULL, FLAG_ADVANCED}, 
 #endif
-	{"ldap suffix", P_STRING, P_GLOBAL, &Globals.szLdapSuffix, handle_ldap_suffix, NULL, FLAG_ADVANCED}, 
-	{"ldap machine suffix", P_STRING, P_GLOBAL, &Globals.szLdapMachineSuffix, handle_ldap_sub_suffix, NULL, FLAG_ADVANCED}, 
-	{"ldap user suffix", P_STRING, P_GLOBAL, &Globals.szLdapUserSuffix, handle_ldap_sub_suffix, NULL, FLAG_ADVANCED}, 
-	{"ldap group suffix", P_STRING, P_GLOBAL, &Globals.szLdapGroupSuffix, handle_ldap_sub_suffix, NULL, FLAG_ADVANCED}, 
-	{"ldap idmap suffix", P_STRING, P_GLOBAL, &Globals.szLdapIdmapSuffix, handle_ldap_sub_suffix, NULL, FLAG_ADVANCED}, 
+	{"ldap suffix", P_STRING, P_GLOBAL, &Globals.szLdapSuffix, NULL, NULL, FLAG_ADVANCED}, 
+	{"ldap machine suffix", P_STRING, P_GLOBAL, &Globals.szLdapMachineSuffix, NULL, NULL, FLAG_ADVANCED}, 
+	{"ldap user suffix", P_STRING, P_GLOBAL, &Globals.szLdapUserSuffix, NULL, NULL, FLAG_ADVANCED}, 
+	{"ldap group suffix", P_STRING, P_GLOBAL, &Globals.szLdapGroupSuffix, NULL, NULL, FLAG_ADVANCED}, 
+	{"ldap idmap suffix", P_STRING, P_GLOBAL, &Globals.szLdapIdmapSuffix, NULL, NULL, FLAG_ADVANCED}, 
 	{"ldap filter", P_STRING, P_GLOBAL, &Globals.szLdapFilter, NULL, NULL, FLAG_ADVANCED}, 
 	{"ldap admin dn", P_STRING, P_GLOBAL, &Globals.szLdapAdminDn, NULL, NULL, FLAG_ADVANCED}, 
 	{"ldap ssl", P_ENUM, P_GLOBAL, &Globals.ldap_ssl, NULL, enum_ldap_ssl, FLAG_ADVANCED}, 
@@ -1686,10 +1683,6 @@
 FN_GLOBAL_INTEGER(lp_ldap_port, &Globals.ldap_port)
 #endif
 FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
-FN_GLOBAL_STRING(lp_ldap_machine_suffix, &Globals.szLdapMachineSuffix)
-FN_GLOBAL_STRING(lp_ldap_user_suffix, &Globals.szLdapUserSuffix)
-FN_GLOBAL_STRING(lp_ldap_idmap_suffix, &Globals.szLdapIdmapSuffix)
-FN_GLOBAL_STRING(lp_ldap_group_suffix, &Globals.szLdapGroupSuffix)
 FN_GLOBAL_STRING(lp_ldap_filter, &Globals.szLdapFilter)
 FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
@@ -2988,56 +2981,39 @@
 }
 
 /***************************************************************************
- Handle setting ldap suffix and determines whether ldap machine suffix needs
- to be set as well.
- 
- Set all of the sub suffix strings to be the 'ldap suffix' by default
+ Handle ldap suffixes - default to ldapsuffix if sub-suffixes are not defined.
 ***************************************************************************/
 
-static BOOL handle_ldap_suffix( const char *pszParmValue, char **ptr )
+char *lp_ldap_machine_suffix()
 {
-	pstring suffix;
-               
-	pstrcpy(suffix, pszParmValue);
+	if (Globals.szLdapMachineSuffix[0])
+		return lp_string(Globals.szLdapMachineSuffix);
 
-	/* set defaults for the the sub-suffixes */
-	
-	if (! *Globals.szLdapMachineSuffix )
-		string_set(&Globals.szLdapMachineSuffix, suffix);
-	if (! *Globals.szLdapUserSuffix ) 
-		string_set(&Globals.szLdapUserSuffix, suffix);
-	if (! *Globals.szLdapGroupSuffix ) 
-		string_set(&Globals.szLdapGroupSuffix, suffix);
-	if (! *Globals.szLdapIdmapSuffix ) 
-		string_set(&Globals.szLdapIdmapSuffix, suffix);
+	return lp_string(Globals.szLdapSuffix);
+}
 
-	string_set(ptr, suffix); 
-	return True;
+char *lp_ldap_user_suffix()
+{
+	if (Globals.szLdapUserSuffix[0])
+		return lp_string(Globals.szLdapUserSuffix);
+
+	return lp_string(Globals.szLdapSuffix);
 }
 
-/***************************************************************************
- Handle the ldap sub suffix option.
- Always append the 'ldap suffix' if it is set
-***************************************************************************/
+char *lp_ldap_group_suffix()
+{
+	if (Globals.szLdapGroupSuffix[0])
+		return lp_string(Globals.szLdapGroupSuffix);
+
+	return lp_string(Globals.szLdapSuffix);
+}
 
-static BOOL handle_ldap_sub_suffix( const char *pszParmValue, char **ptr)
+char *lp_ldap_idmap_suffix()
 {
-	pstring suffix;
-       
-	pstrcpy(suffix, pszParmValue);
+	if (Globals.szLdapIdmapSuffix[0])
+		return lp_string(Globals.szLdapIdmapSuffix);
 
-	if (! *Globals.szLdapSuffix ) {
-		string_set( ptr, suffix );
-		return True;
-	}
-	else {
-		if ( *pszParmValue )
-			pstrcat(suffix, ",");
-		pstrcat(suffix, Globals.szLdapSuffix);
-	}
-	
-	string_set( ptr, suffix );
-	return True;
+	return lp_string(Globals.szLdapSuffix);
 }
 
 /***************************************************************************


More information about the samba-technical mailing list