* Added the necessary glue code for importing LDAP attributes into a user's vCard...
authorArt Cancro <ajc@citadel.org>
Mon, 28 Sep 2009 19:05:51 +0000 (19:05 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 28 Sep 2009 19:05:51 +0000 (19:05 +0000)
citadel/citadel_ldap.h
citadel/ldap.c
citadel/modules/vcard/serv_vcard.c

index fb775d96d019a41712d9d632b917fc9e6d7d7056..3e98ddb1555fa6fca2c51ba2765c4c448b6c37dd 100644 (file)
@@ -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);
index bdf01e16f4b129ba78b7c839784ef698a70b4129..1bc38224c2a15a66b30fade8378a7ae40f94f160 100644 (file)
@@ -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 */
index 18b30ae6eadb883d1b301b36e469b5fde8af4991..4e41299808a55b571ae1f97dbe06c0d5cd97d68e 100644 (file)
@@ -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
  */
 
 /*
 #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