* More license declarations
[citadel.git] / citadel / modules / vcard / serv_vcard.c
index 46b7cb1f8f952e7d2fa97b8b874e19902d5f6bf8..f31b538b838aa197dfcc21c0bf98d08351a4084d 100644 (file)
@@ -4,7 +4,21 @@
  * 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 by the citadel.org team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 /*
 #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 +95,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;
@@ -1184,24 +1195,34 @@ void vcard_create_room(void)
  */
 void vcard_session_login_hook(void) {
        struct vCard *v = NULL;
+       struct CitContext *CCC = CC;            /* put this on the stack, just for speed */
 
+#ifdef HAVE_LDAP
        /*
         * Is this an LDAP session?  If so, copy various LDAP attributes from the directory entry
         * into the user's vCard.
         */
-       /*   FIXME THIS IS NOT IMPLEMENTED YET */
+       if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+               v = vcard_get_user(&CCC->user);
+               if (v) {
+                       if (Ctdl_LDAP_to_vCard(CCC->ldap_dn, v)) {
+                               vcard_write_user(&CCC->user, v);
+                       }
+               }
+       }
+#endif
 
        /*
         * Extract from the user's vCard, any Internet email addresses and the user's real name.
         * These are inserted into the session data for various message entry commands to use.
         */
-       v = vcard_get_user(&CC->user);
+       v = vcard_get_user(&CCC->user);
        if (v) {
-               extract_inet_email_addrs(CC->cs_inet_email, sizeof CC->cs_inet_email,
-                                       CC->cs_inet_other_emails, sizeof CC->cs_inet_other_emails,
+               extract_inet_email_addrs(CCC->cs_inet_email, sizeof CCC->cs_inet_email,
+                                       CCC->cs_inet_other_emails, sizeof CCC->cs_inet_other_emails,
                                        v, 1
                );
-               extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v);
+               extract_friendly_name(CCC->cs_inet_fn, sizeof CCC->cs_inet_fn, v);
                vcard_free(v);
        }