X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fldap.c;fp=citadel%2Fldap.c;h=864ab4807230af05da9e63e6871f781defc19383;hp=a6f3db3c275f035e4a570b7664a2a18d6acfc008;hb=6ae0819ac13984a0dfa583281fc0081af735c77d;hpb=1aa2da0249792527f99172681aecc77e0ad086af diff --git a/citadel/ldap.c b/citadel/ldap.c index a6f3db3c2..864ab4807 100644 --- a/citadel/ldap.c +++ b/citadel/ldap.c @@ -42,6 +42,7 @@ int CtdlTryUserLDAP(char *username, char **values; char *user_dn = NULL; +#ifndef LDAP_INITIALIZE if (fullname) safestrncpy(fullname, username, fullname_size); ldserver = ldap_init(config.c_ldap_host, config.c_ldap_port); @@ -67,6 +68,31 @@ int CtdlTryUserLDAP(char *username, syslog(LOG_ALERT, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i); return(i); } +#else + if (ldap_initialize(&ldserver, config.c_ldap_host)) + { + syslog(LOG_ALERT, "LDAP: Could not connect to %s:%d : %s\n", + config.c_ldap_host, config.c_ldap_port, + strerror(errno) + ); + return(errno); + } + + striplt(config.c_ldap_bind_dn); + striplt(config.c_ldap_bind_pw); + + syslog(LOG_DEBUG, "LDAP bind DN: %s\n", config.c_ldap_bind_dn); + i = ldap_simple_bind_s(ldserver, + (!IsEmptyStr(config.c_ldap_bind_dn) ? config.c_ldap_bind_dn : NULL), + (!IsEmptyStr(config.c_ldap_bind_pw) ? config.c_ldap_bind_pw : NULL) + ); + + if (i != LDAP_SUCCESS) { + syslog(LOG_ALERT, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i); + return(i); + } +#endif + tv.tv_sec = 10; tv.tv_usec = 0;