- if (ctdl_ldap_initialize(&ldserver) != LDAP_SUCCESS) {
- return(0);
- }
-
- ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
- ldap_set_option(ldserver, LDAP_OPT_REFERRALS, (void *)LDAP_OPT_OFF);
-
- striplt(CtdlGetConfigStr("c_ldap_bind_dn"));
- striplt(CtdlGetConfigStr("c_ldap_bind_pw"));
- syslog(LOG_DEBUG, "ldap: bind DN: %s", CtdlGetConfigStr("c_ldap_bind_dn"));
- i = ldap_simple_bind_s(ldserver,
- (!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_dn")) ? CtdlGetConfigStr("c_ldap_bind_dn") : NULL),
- (!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_pw")) ? CtdlGetConfigStr("c_ldap_bind_pw") : NULL)
- );
- if (i != LDAP_SUCCESS) {
- syslog(LOG_ERR, "ldap: Cannot bind: %s (%d)", ldap_err2string(i), i);
- return(0);
- }