From: Art Cancro Date: Mon, 28 Sep 2009 19:05:51 +0000 (+0000) Subject: * Added the necessary glue code for importing LDAP attributes into a user's vCard... X-Git-Tag: v7.86~827 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=101a081c8c4cc505daf9e102d2b7567cc6194cf2 * Added the necessary glue code for importing LDAP attributes into a user's vCard when they log in. Search ldap.c for the string 'LDAPSTUB' to find the location where the attribute code must be written. Right now it is a stub function. --- diff --git a/citadel/citadel_ldap.h b/citadel/citadel_ldap.h index fb775d96d..3e98ddb15 100644 --- a/citadel/citadel_ldap.h +++ b/citadel/citadel_ldap.h @@ -6,3 +6,4 @@ int CtdlTryUserLDAP(char *username, char *found_dn, int found_dn_size, char *fullname, int fullname_size, uid_t *found_uid); int CtdlTryPasswordLDAP(char *user_dn, char *password); +int Ctdl_LDAP_to_vCard(char *ldap_dn, struct vCard *v); diff --git a/citadel/ldap.c b/citadel/ldap.c index bdf01e16f..1bc38224c 100644 --- a/citadel/ldap.c +++ b/citadel/ldap.c @@ -236,6 +236,27 @@ int CtdlTryPasswordLDAP(char *user_dn, char *password) } +/* + * Learn LDAP attributes and stuff them into the vCard. + * Returns nonzero if we changed anything. + */ +int Ctdl_LDAP_to_vCard(char *ldap_dn, struct vCard *v) +{ + if (!ldap_dn) return(0); + if (!v) return(0); + + /* + * FIXME LDAPSTUB this is a stub function + * + * ldap_dn will contain the DN of the user, and v will contain a pointer to + * the vCard that needs to be (re-)populated. Put the requisite LDAP code here. + * + vcard_set_prop(v, "email;internet", xxx, 0); + return(1); * return nonzero to tell the caller that we made changes that need to be saved * + * + */ + return(0); /* return zero to tell the caller that we didn't make any changes */ +} #endif /* HAVE_LDAP */ diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index 18b30ae6e..4e4129980 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -4,7 +4,7 @@ * A server-side module for Citadel which supports address book information * using the standard vCard format. * - * Copyright (c) 1999-2007 / released under the GNU General Public License + * Copyright (c) 1999-2009 / released under the GNU General Public License v3 */ /* @@ -61,11 +61,9 @@ #include "msgbase.h" #include "internet_addressing.h" #include "serv_vcard.h" - +#include "citadel_ldap.h" #include "ctdl_module.h" - - /* * set global flag calling for an aide to validate new users */ @@ -83,8 +81,7 @@ void set_mm_valid(void) { * Extract Internet e-mail addresses from a message containing a vCard, and * perform a callback for any found. */ -void vcard_extract_internet_addresses(struct CtdlMessage *msg, - void (*callback)(char *, char *) ) { +void vcard_extract_internet_addresses(struct CtdlMessage *msg, void (*callback)(char *, char *) ) { struct vCard *v; char *s; char *k; @@ -1192,11 +1189,12 @@ void vcard_session_login_hook(void) { * into the user's vCard. */ if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) { - - /* FIXME do something with this. - * The DN of the account will be found in: CCC->ldap_dn - */ - + v = vcard_get_user(&CCC->user); + if (v) { + if (Ctdl_LDAP_to_vCard(CCC->ldap_dn, v)) { + vcard_write_user(&CCC->user, v); + } + } } #endif