]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
* Added a separate authentication mode AUTHMODE_LDAP_AD for Active Directory's nonsta...
[citadel.git] / citadel / user_ops.c
index 099ca517ff90ada84ae5cd39de5d06d7acb0191d..bb803982af93da8fb8a1c23d4187079eeb86483d 100644 (file)
@@ -543,11 +543,11 @@ int CtdlLoginExistingUser(char *authname, char *trythisname)
        }
 
 #ifdef HAVE_LDAP
-       else if (config.c_auth_mode == AUTHMODE_LDAP) {
+       else if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
        
                /* LDAP auth mode */
 
-               int ldap_uid;
+               uid_t ldap_uid;
                char ldap_cn[256];
                char ldap_dn[256];
 
@@ -558,7 +558,7 @@ int CtdlLoginExistingUser(char *authname, char *trythisname)
 
                found_user = getuserbyuid(&CC->user, ldap_uid);
                if (found_user != 0) {
-                       create_user(ldap_cn, 0);
+                       create_user(trythisname, 0);
                        found_user = getuserbyuid(&CC->user, ldap_uid);
                }
 
@@ -890,7 +890,7 @@ int CtdlTryPassword(char *password)
        }
 
 #ifdef HAVE_LDAP
-       else if (config.c_auth_mode == AUTHMODE_LDAP) {
+       else if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
 
                /* LDAP auth mode */
 
@@ -1111,7 +1111,13 @@ int create_user(char *newusername, int become_user)
                }
        }
 
-       /* FIXME_LDAP put something here */
+#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;