]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
Started prepping for the move from LDAP Access to LDAP Sync
[citadel.git] / citadel / user_ops.c
index 87dfa5a2515eea16776664d26640f1f8094526cb..5cdd4977a6881c1692755ccfc3bfe23845c17034 100644 (file)
@@ -461,8 +461,10 @@ void rebuild_usersbynumber(void) {
  * getuserbyuid()  -     get user by system uid (for PAM mode authentication)
  *                    returns 0 if user was found
  *
- * WARNING: don't use this function unless you absolutely have to.  It does
- *       a sequential search and therefore is computationally expensive.
+ * WARNING:    don't use this function unless you absolutely have to.  It does
+ *             a sequential search and therefore is computationally expensive.
+ *
+ * FIXME:      build an index, dummy.
  */
 int getuserbyuid(struct ctdluser *usbuf, uid_t number)
 {
@@ -662,14 +664,18 @@ void do_login(void)
                }
        }
 
-       CtdlPutUserLock(&CCC->user);
-
-
-       // PUT THE EMAIL EXTRACT HERE AJC FIXME
-       //#ifdef HAVE_LDAP
-               //if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
-               //int extract_email_addresses_from_ldap(char *ldap_dn, char *emailaddrs)
-       //#endif
+       /*
+        * If we are using LDAP authentication, extract the user's email addresses from the directory.
+        * FIXME make this a site configurable setting
+        */
+       #ifdef HAVE_LDAP
+               if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
+                       char new_emailaddrs[512];
+                       if (extract_email_addresses_from_ldap(CCC->ldap_dn, new_emailaddrs) == 0) {
+                               strcpy(CCC->user.emailaddrs, new_emailaddrs);
+                       }
+               }
+       #endif
 
        /*
         * No email address for user?  Make one up.
@@ -678,6 +684,8 @@ void do_login(void)
                sprintf(CCC->user.emailaddrs, "cit%ld@%s", CCC->user.usernum, CtdlGetConfigStr("c_fqdn"));
        }
        
+       CtdlPutUserLock(&CCC->user);
+
        /*
         * Populate cs_inet_email and cs_inet_other_emails with valid email addresses from the user record
         */