[Samba] Re: samba (2.2.7a) + openldap (2.0.x)

C.Lee Taylor leet at leenx.co.za
Thu Jan 9 06:40:01 GMT 2003


 >
 >Seems I was wrong (left out ldap switch ...), it doesn't compile on
 >cooker, here is the error:
 >
 >Compiling passdb/pdb_ldap.c
 >passdb/pdb_ldap.c: In function `ldap_connect_system':
 >passdb/pdb_ldap.c:289: warning: passing arg 2 of `ldap_set_rebind_proc'
 >from incompatible pointer type
 >passdb/pdb_ldap.c:289: too many arguments to function 
 >`ldap_set_rebind_proc'
 >make: *** [passdb/pdb_ldap.o] Error 1

	What the real problem, is that the ldap_set_rebind_proc now takes 2 par 
instead of 3.  On line 289 ( I think remove the ",NULL" from the call 
and recompile.  It should then recompile fine.

	I am testing this at the moment.  I now wish I could figure out the 
autoconf stuff so that it could be tested for.

	I hope this helps.  Please let me know if it works for you.

Mailed
Lee



-------------- next part --------------
--- samba-2.2.7/source/passdb/pdb_ldap.c.ldap	2002-12-10 16:58:15.000000000 +0200
+++ samba-2.2.7/source/passdb/pdb_ldap.c	2003-01-08 18:38:19.000000000 +0200
@@ -65,6 +65,7 @@
 
 static struct ldap_enum_info global_ldap_ent;
 
+static pstring ldap_secret;
 
 extern pstring samlogon_user;
 extern BOOL sam_logon_in_ssb;
@@ -218,13 +219,60 @@
 }
 
 /*******************************************************************
+ ldap rebind proc to rebind w/ the admin dn when following referrals
+*******************************************************************/
+#if defined(LDAP_API_FEATURE_X_OPENLDAP) && (LDAP_API_VERSION > 2000)
+/** @TODO Add a configure check for the rebind_proc version that doesn't take
+    the last argument and include a #define here. */
+static int auth_rebind_proc( LDAP *ld,
+                             LDAP_CONST char *url,
+                             ber_tag_t request,
+                             ber_int_t msgid,
+                             void *arg)
+{
+    int rc;
+    if ( ( rc = ldap_simple_bind_s( ld, lp_ldap_admin_dn(), ldap_secret ) ) == LDAP_SUCCESS )
+    {
+        DEBUG( 2, ( "Rebind successful\n" ) );
+    }
+    else {
+        DEBUG( 0, ( "Rebind failed: %s\n", ldap_err2string( rc ) ) );
+    }
+    return rc;
+}
+#else
+static int auth_rebind_proc ( LDAP * ld,
+                              char **whop,
+                              char **credp,
+                              int *methodp,
+                              int freeit,
+                              void *arg )
+{
+    /** @TODO Use the samba utility functions here. */
+    register char   *to_clear = *credp;
+    if ( freeit ) {
+        free( *whop );
+        *whop = NULL;
+        while ( *to_clear != '\0' ) *to_clear++ = '\0';
+        free( *credp );
+        *credp = NULL;
+    }
+    else {
+        *whop = strdup( lp_ldap_admin_dn() );
+        *credp = strdup( ldap_secret );
+        *methodp = LDAP_AUTH_SIMPLE;
+    }
+    return LDAP_SUCCESS;
+}
+#endif
+
+/*******************************************************************
  connect to the ldap server under system privilege.
 ******************************************************************/
 static BOOL ldap_connect_system(LDAP * ldap_struct)
 {
 	int rc;
 	static BOOL got_pw = False;
-	static pstring ldap_secret;
 
 	/* get the password if we don't have it already */
 	if (!got_pw && !(got_pw=fetch_ldap_pw(lp_ldap_admin_dn(), ldap_secret, sizeof(pstring)))) 
@@ -237,6 +285,12 @@
 	/* removed the sasl_bind_s "EXTERNAL" stuff, as my testsuite 
 	   (OpenLDAP) doesnt' seem to support it */
 	   
+    DEBUG( 10, ( "ldap_connect_system: setting rebind proc\n " ) );
+    if ( ( rc = ldap_set_rebind_proc( ldap_struct, auth_rebind_proc ) ) != LDAP_SUCCESS )
+    {
+        DEBUG( 2, ( "   warning: setting rebind proc failed: %s\n referrals may not work\n", ldap_err2string( rc ) ) );
+    }
+    
 	DEBUG(10,("ldap_connect_system: Binding to ldap server as \"%s\"\n",
 		lp_ldap_admin_dn()));
 		


More information about the samba mailing list