]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
Removed the remaining code where LDAP was optional.
[citadel.git] / citadel / user_ops.c
index 168f224fbc3a183cad447d978e61f09c4099334b..a8f7b34233039dd41e7cc9d736fd53410c60995c 100644 (file)
@@ -1,16 +1,14 @@
-/* 
- * Server functions which perform operations on user objects.
- *
- * Copyright (c) 1987-2020 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// Server functions which perform operations on user objects.
+//
+// Copyright (c) 1987-2021 by the citadel.org team
+//
+// This program is open source software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License, version 3.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 
 #include <stdlib.h>
 #include <unistd.h>
@@ -84,9 +82,12 @@ int CtdlGetUser(struct ctdluser *usbuf, char *name)
        }
 
        makeuserkey(usernamekey, name);
+       if (IsEmptyStr(usernamekey)) {
+               return(1);      // empty user name
+       }
        cdbus = cdb_fetch(CDB_USERS, usernamekey, strlen(usernamekey));
 
-       if (cdbus == NULL) {    /* user not found */
+       if (cdbus == NULL) {    // user not found
                return(1);
        }
        if (usbuf != NULL) {
@@ -592,7 +593,6 @@ int CtdlLoginExistingUser(const char *trythisname)
 
        }
 
-#ifdef HAVE_LDAP
        else if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
        
                /* LDAP auth mode */
@@ -618,12 +618,11 @@ int CtdlLoginExistingUser(const char *trythisname)
                }
 
        }
-#endif
 
        else {
                /* native auth mode */
 
-               recptypes *valid = NULL;
+               struct recptypes *valid = NULL;
        
                /* First, try to log in as if the supplied name is a display name */
                found_user = CtdlGetUser(&CC->user, username);
@@ -682,7 +681,6 @@ void do_login(void)
        CtdlPutUserLock(&CC->user);
 
        /* If we are using LDAP authentication, extract the user's email addresses from the directory. */
-#ifdef HAVE_LDAP
        if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
                char new_emailaddrs[512];
                if (CtdlGetConfigInt("c_ldap_sync_email_addrs") > 0) {
@@ -691,7 +689,6 @@ void do_login(void)
                        }
                }
        }
-#endif
 
        /* If the user does not have any email addresses assigned, generate one. */
        if (IsEmptyStr(CC->user.emailaddrs)) {
@@ -699,7 +696,7 @@ void do_login(void)
        }
 
        /* Populate the user principal identity, which is consistent and never aliased */
-       strcpy(CC->cs_principal_id, "wowowowow");
+       strcpy(CC->cs_principal_id, "");
        makeuserkey(CC->cs_principal_id, CC->user.fullname);
        strcat(CC->cs_principal_id, "@");
        strcat(CC->cs_principal_id, CtdlGetConfigStr("c_fqdn"));
@@ -914,7 +911,6 @@ int CtdlTryPassword(const char *password, long len)
                }
        }
 
-#ifdef HAVE_LDAP
        else if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
 
                /* LDAP auth mode */
@@ -926,7 +922,6 @@ int CtdlTryPassword(const char *password, long len)
                        code = (-1);
                }
        }
-#endif
 
        else {