diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2012-09-01 20:17:23 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2012-09-01 20:17:23 +0000 |
commit | b0e7a2c0002b81dd99ba57a8c99bdb9589afb417 (patch) | |
tree | 478ee847af0de62f6c694ed8b1c133fe12a49b69 | |
parent | b7a3cd1de73a074cbcefe4943539a3cf4cd104dc (diff) |
provide an alternative do_rebind() for Netscape LDAP
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1745 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r-- | nslcd/myldap.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/nslcd/myldap.c b/nslcd/myldap.c index 5276c84..de6e670 100644 --- a/nslcd/myldap.c +++ b/nslcd/myldap.c @@ -497,6 +497,7 @@ static int do_bind(LDAP *ld,const char *binddn,const char *bindpw,const char *ur #ifdef HAVE_LDAP_SET_REBIND_PROC /* This function is called by the LDAP library when chasing referrals. It is configured with the ldap_set_rebind_proc() below. */ +#if defined(LDAP_API_FEATURE_X_OPENLDAP) && (LDAP_API_VERSION > 2000) static int do_rebind(LDAP *ld,LDAP_CONST char *url, ber_tag_t UNUSED(request), ber_int_t UNUSED(msgid),void *arg) @@ -505,6 +506,34 @@ static int do_rebind(LDAP *ld,LDAP_CONST char *url, log_log(LOG_DEBUG,"rebinding to %s",url); return do_bind(ld,session->binddn,session->bindpw,url); } +#else /* not recent OpenLDAP */ +static int do_rebind(LDAP *ld,char **dnp,char **passwdp,int *authmethodp, + int freeit,void *arg) +{ + MYLDAP_SESSION *session=(MYLDAP_SESSION *)arg; + if (freeit) + { + free(*dnp); + memset(*passwdp,0,strlen(*passwdp)); + free(*passwdp); + } + else + { + log_log(LOG_DEBUG,"rebinding"); + *dnp=strdup(session->binddn); + *passwdp=strdup(session->bindpw); + *authmethodp=LDAP_AUTH_SIMPLE; + if ((*dnp==NULL)||(*passwdp==NULL)) + { + if (*dnp!=NULL) + free(*dnp); + log_log(LOG_CRIT,"do_rebind(): strdup() failed to allocate memory"); + return LDAP_NO_MEMORY; + } + } + return LDAP_SUCCESS; +} +#endif /* not recent OpenLDAP */ #endif /* HAVE_LDAP_SET_REBIND_PROC */ /* set a recieve and send timeout on a socket */ |