New site setting c_ldap_sync_email_addrs to toggle synchronization of email addresses...
[citadel.git] / citadel / user_ops.c
index 82f693a4ea0a83a1395818ea4688b248d24fd66b..5dc4790a915ac1730a88e5be299cbb0ef3bced81 100644 (file)
@@ -654,14 +654,16 @@ void do_login(void)
         * 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];
+#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) {
                        if (extract_email_addresses_from_ldap(CCC->ldap_dn, new_emailaddrs) == 0) {
-                               strcpy(CCC->user.emailaddrs, new_emailaddrs);
+                               CtdlSetEmailAddressesForUser(CCC->user.fullname, new_emailaddrs);
                        }
                }
-       #endif
+       }
+#endif
 
        /*
         * No email address for user?  Make one up.