#include "citadel_dirs.h"
#include "genstamp.h"
#include "threads.h"
+#include "citadel_ldap.h"
/* These pipes are used to talk to the chkpwd daemon, which is forked during startup */
int chkpwd_write_pipe[2];
}
+#ifdef HAVE_LDAP
+ else if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+
+ /* LDAP auth mode */
+
+ uid_t ldap_uid;
+ char ldap_cn[256];
+ char ldap_dn[256];
+
+ found_user = CtdlTryUserLDAP(username, ldap_dn, sizeof ldap_dn, ldap_cn, sizeof ldap_cn, &ldap_uid);
+ if (found_user != 0) {
+ return login_not_found;
+ }
+
+ found_user = getuserbyuid(&CC->user, ldap_uid);
+ if (found_user != 0) {
+ create_user(trythisname, 0);
+ found_user = getuserbyuid(&CC->user, ldap_uid);
+ }
+
+ if (found_user == 0) {
+ if (CC->ldap_dn != NULL) free(CC->ldap_dn);
+ CC->ldap_dn = strdup(ldap_dn);
+ }
+
+ }
+#endif
+
else {
/* native auth mode */
}
}
+#ifdef HAVE_LDAP
+ else if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+
+ /* LDAP auth mode */
+
+ if ((CC->ldap_dn) && (!CtdlTryPasswordLDAP(CC->ldap_dn, password))) {
+ code = 0;
+ }
+ else {
+ code = (-1);
+ }
+ }
+#endif
+
else {
/* native auth mode */
return (ERROR + NO_SUCH_USER);
}
}
+
+#ifdef HAVE_LDAP
+ if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+ if (CtdlTryUserLDAP(username, NULL, 0, username, sizeof username, &uid) != 0) {
+ return(ERROR + NO_SUCH_USER);
+ }
+ }
+#endif /* HAVE_LDAP */
if ((retval = internal_create_user(username, &usbuf, uid)) != 0)
return retval;