[PATCH] ldap rebind sleep

Stefan Metzmacher metze at metzemix.de
Tue Nov 11 22:03:54 GMT 2003


Hi Guenther, Hi Andrew,

here's the ldap rebind sleep patch

gd: can you test it and report if it works ok,
because I modified my old version a bit.

-- 

metze

-------------------------------------------
Stefan (metze) Metzmacher <metze at metzemix.de>

-------------- next part --------------
Index: include/smbldap.h
===================================================================
RCS file: /cvsroot/samba/source/include/smbldap.h,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 smbldap.h
--- include/smbldap.h	18 Sep 2003 23:53:47 -0000	1.1.2.8
+++ include/smbldap.h	11 Nov 2003 20:18:14 -0000
@@ -137,6 +137,8 @@
 
 	time_t last_use;
 	smb_event_id_t event_id;
+	
+	BOOL rebind_delay;
 };
 
 #endif 	/* HAVE_LDAP */
Index: lib/smbldap.c
===================================================================
RCS file: /cvsroot/samba/source/lib/smbldap.c,v
retrieving revision 1.1.2.18
diff -u -r1.1.2.18 smbldap.c
--- lib/smbldap.c	29 Oct 2003 21:27:59 -0000	1.1.2.18
+++ lib/smbldap.c	11 Nov 2003 20:18:17 -0000
@@ -641,6 +641,8 @@
 	    Could we get a referral to a machine that we don't want to give our
 	    username and password to? */
 	
+	ldap_state->rebind_delay = True;
+	
 	if (freeit) {
 		SAFE_FREE(*whop);
 		memset(*credp, '\0', strlen(*credp));
@@ -684,6 +686,8 @@
 	    Could we get a referral to a machine that we don't want to give our
 	    username and password to? */
 
+	ldap_state->rebind_delay = True;
+
 	rc = ldap_simple_bind_s(ldap_struct, ldap_state->bind_dn, ldap_state->bind_secret);
 	
 	return rc;
@@ -960,6 +964,13 @@
 	ldap_state->last_use = time(NULL);
 
 	SAFE_FREE(utf8_dn);
+
+	if (ldap_state->rebind_delay == True) {
+		/* we wait for the LDAP replication */
+		usleep(1000*lp_ldap_rebind_sleep());
+		ldap_state->rebind_delay = False;
+	}
+
 	return rc;
 }
 
@@ -987,10 +998,17 @@
 		DEBUG(0,("%s: LDAP server is down!\n",FUNCTION_MACRO));
 		smbldap_close(ldap_state);	
 	}
-		
+
 	ldap_state->last_use = time(NULL);
 
 	SAFE_FREE(utf8_dn);
+
+	if (ldap_state->rebind_delay == True) {
+		/* we wait for the LDAP replication */
+		usleep(100*lp_ldap_rebind_sleep());
+		ldap_state->rebind_delay = False;
+	}
+
 	return rc;
 }
 
@@ -1022,6 +1040,13 @@
 	ldap_state->last_use = time(NULL);
 
 	SAFE_FREE(utf8_dn);
+
+	if (ldap_state->rebind_delay == True) {
+		/* we wait for the LDAP replication */
+		usleep(1000*lp_ldap_rebind_sleep());
+		ldap_state->rebind_delay = False;
+	}
+
 	return rc;
 }
 
@@ -1051,6 +1076,12 @@
 	}
 		
 	ldap_state->last_use = time(NULL);
+
+	if (ldap_state->rebind_delay == True) {
+		/* we wait for the LDAP replication */
+		usleep(1000*lp_ldap_rebind_sleep());
+		ldap_state->rebind_delay = False;
+	}
 
 	return rc;
 }
Index: param/loadparm.c
===================================================================
RCS file: /cvsroot/samba/source/param/loadparm.c,v
retrieving revision 1.397.2.106
diff -u -r1.397.2.106 loadparm.c
--- param/loadparm.c	6 Nov 2003 22:07:12 -0000	1.397.2.106
+++ param/loadparm.c	11 Nov 2003 20:18:27 -0000
@@ -232,7 +232,8 @@
 	char *szLdapFilter;
 	char *szLdapAdminDn;
 	char *szAclCompat;
-	int ldap_passwd_sync; 
+	int ldap_passwd_sync;
+	int ldap_rebind_sleep;
 	BOOL ldap_delete_dn;
 	BOOL bMsAddPrinterWizard;
 	BOOL bDNSproxy;
@@ -1074,6 +1075,7 @@
 	{"ldap ssl", P_ENUM, P_GLOBAL, &Globals.ldap_ssl, NULL, enum_ldap_ssl, FLAG_ADVANCED}, 
 	{"ldap passwd sync", P_ENUM, P_GLOBAL, &Globals.ldap_passwd_sync, NULL, enum_ldap_passwd_sync, FLAG_ADVANCED}, 
 	{"ldap delete dn", P_BOOL, P_GLOBAL, &Globals.ldap_delete_dn, NULL, NULL, FLAG_ADVANCED}, 
+	{"ldap rebind sleep", P_INTEGER, P_GLOBAL, &Globals.ldap_rebind_sleep, NULL, NULL, FLAG_ADVANCED},
 
 	{N_("Miscellaneous Options"), P_SEP, P_SEPARATOR}, 
 	{"add share command", P_STRING, P_GLOBAL, &Globals.szAddShareCommand, NULL, NULL, FLAG_ADVANCED}, 
@@ -1465,6 +1467,7 @@
 	Globals.ldap_ssl = LDAP_SSL_ON;
 	Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
 	Globals.ldap_delete_dn = False;
+	Globals.ldap_rebind_sleep = 500*1000; /* wait 0.5 s for replication */
 
 /* these parameters are set to defaults that are more appropriate
    for the increasing samba install base:
@@ -1698,6 +1701,7 @@
 FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
 FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
 FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
+FN_GLOBAL_INTEGER(lp_ldap_rebind_sleep, &Globals.ldap_rebind_sleep)
 FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
 FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
 FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)


More information about the samba-technical mailing list