From: Art Cancro Date: Mon, 11 Sep 2017 01:21:10 +0000 (-0400) Subject: Copy email addresses from LDAP X-Git-Tag: v939~524 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=56e1a9496ac3e2445f44c5cdfee4b3b28134c65e Copy email addresses from LDAP --- diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 87dfa5a25..0a61cb0e2 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -662,14 +662,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 +682,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 */