Index: rlm_ldap.c =================================================================== RCS file: /source/radiusd/src/modules/rlm_ldap/rlm_ldap.c,v retrieving revision 1.123 diff -u -r1.123 rlm_ldap.c --- rlm_ldap.c 6 Jul 2004 19:07:17 -0000 1.123 +++ rlm_ldap.c 15 Jul 2004 12:57:50 -0000 @@ -349,6 +349,10 @@ static int ldap_xlat(void *,REQUEST *, char *, char *,int, RADIUS_ESCAPE_STRING); static LDAP *ldap_connect(void *instance, const char *, const char *, int, int *); static int read_mappings(ldap_instance* inst); +static int ldap_rebind(LDAP *ld,LDAP_CONST char *url,ber_tag_t request, ber_int_t msgid,void *params ); + +char *DN; +char *PASSWD; static inline int ldap_get_conn(LDAP_CONN *conns,LDAP_CONN **ret,void *instance) { @@ -561,6 +565,9 @@ *instance = inst; + DN = inst->login; + PASSWD = inst->password; + return 0; } @@ -1538,6 +1545,14 @@ return RLM_MODULE_OK; } +static int ldap_rebind(LDAP *ld,LDAP_CONST char *url,ber_tag_t request, ber_int_t msgid,void *params ) +{ + if (DN != NULL && PASSWD != NULL){ + DEBUG("rlm_ldap: rebind to URL: %s",url); + return ldap_bind_s( ld, dn, passwd, LDAP_AUTH_SIMPLE); + } +} + static LDAP * ldap_connect(void *instance, const char *dn, const char *password, int auth, int *result) { @@ -1578,6 +1593,7 @@ if (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &ldap_version) != LDAP_OPT_SUCCESS) { radlog(L_ERR, "rlm_ldap: Could not set LDAP version to V3"); } + ldap_set_rebind_proc(ld,ldap_rebind,NULL); #ifdef HAVE_LDAP_START_TLS if(inst->tls_mode) { DEBUG("rlm_ldap: setting TLS mode to %d", inst->tls_mode);