]> code.citadel.org Git - citadel.git/commitdiff
* Delete a user's LDAP entry when deleting the vCard. NOT TESTED.
authorArt Cancro <ajc@citadel.org>
Thu, 5 Feb 2004 05:20:20 +0000 (05:20 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 5 Feb 2004 05:20:20 +0000 (05:20 +0000)
citadel/ChangeLog
citadel/serv_ldap.c
citadel/serv_ldap.h
citadel/serv_vcard.c

index 231c496e962482e69c6d7ec64723a7fc5e7784e6..a6d58b2017bf36f0a329f858ab802b19eba9bdb6 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 614.16  2004/02/05 05:20:20  ajc
+ * Delete a user's LDAP entry when deleting the vCard.  NOT TESTED.
+
  Revision 614.15  2004/02/05 03:54:14  ajc
  * Completed the per-user initialization of LDAP entries.
 
@@ -5268,3 +5271,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 69f7222d2777b051990ee292f82579801ace08bb..d72d295e9728e70f14acc63dcf9b7cdc7368ada3 100644 (file)
@@ -198,12 +198,16 @@ void CtdlConnectToLdap(void) {
 }
 
 
-
-/*
- * Write (add, or change if already exists) a directory entry to the
+/* 
+ * vCard-to-LDAP conversions.
+ *
+ * If 'op' is set to V2L_WRITE, then write
+ * (add, or change if already exists) a directory entry to the
  * LDAP server, based on the information supplied in a vCard.
+ *
+ * If 'op' is set to V2L_DELETE, then delete the entry from LDAP.
  */
-void ctdl_vcard_to_ldap(struct CtdlMessage *msg) {
+void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) {
        struct vCard *v = NULL;
        int i, j;
        char this_dn[SIZ];
@@ -230,9 +234,6 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg) {
        if (msg->cm_fields['A'] == NULL) return;
        if (msg->cm_fields['N'] == NULL) return;
 
-       /* First make sure the OU for the user's home Citadel host is created */
-       CtdlCreateHostOU(msg->cm_fields['N']);
-
        /* Initialize variables */
        strcpy(givenname, "_");
        strcpy(sn, "_");
@@ -248,6 +249,26 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg) {
                msg->cm_fields['N']
        );
 
+       /* Are we just deleting?  If so, it's simple... */
+       if (op == V2L_DELETE) {
+               lprintf(9, "Calling ldap_delete_s()\n");
+               begin_critical_section(S_LDAP);
+               i = ldap_delete_s(dirserver, this_dn);
+               end_critical_section(S_LDAP);
+               if (i != LDAP_SUCCESS) {
+                       lprintf(3, "ldap_delete_s() failed: %s (%d)\n",
+                               ldap_err2string(i), i);
+               }
+               return;
+       }
+
+       /*
+        * If we get to this point then it must be a V2L_WRITE operation.
+        */
+
+       /* First make sure the OU for the user's home Citadel host is created */
+       CtdlCreateHostOU(msg->cm_fields['N']);
+
        /* The first LDAP attribute will be an 'objectclass' list.  Citadel
         * doesn't do anything with this.  It's just there for compatibility
         * with Kolab.
@@ -258,13 +279,8 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg) {
        memset(attrs[0], 0, sizeof(LDAPMod));
        attrs[0]->mod_op        = LDAP_MOD_ADD;
        attrs[0]->mod_type      = "objectclass";
-       attrs[0]->mod_values    = mallok(2 * sizeof(char *));
+       attrs[0]->mod_values    = mallok(3 * sizeof(char *));
        attrs[0]->mod_values[0] = strdoop("inetOrgPerson");
-       /*
-       attrs[0]->mod_values[1] = strdoop("organizationalPerson");
-       attrs[0]->mod_values[2] = strdoop("person");
-       attrs[0]->mod_values[3] = strdoop("Top");
-       */
        attrs[0]->mod_values[1] = NULL;
 
        /* Convert the vCard fields to LDAP properties */
@@ -530,7 +546,7 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg) {
                }
        }
        phree(attrs);
-       lprintf(9, "LDAP operation complete.\n");
+       lprintf(9, "LDAP write operation complete.\n");
 }
 
 
index 49fe7ba0a8025655528a8d7db233093a62b1009c..f2595dba9203b22dd82cd82bf3213175d3f23834 100644 (file)
@@ -5,6 +5,11 @@
 
 #ifdef HAVE_LDAP
 
-void ctdl_vcard_to_ldap(struct CtdlMessage *msg);
+void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op);
+
+enum {
+       V2L_WRITE,
+       V2L_DELETE
+};
 
 #endif /* HAVE_LDAP */
index 16947b926aea47309651719437864a16c355547c..5ea0d40680b3cb3edd66d4af6c04c19ddb69c3a7 100644 (file)
@@ -174,7 +174,7 @@ void vcard_add_to_directory(long msgnum, void *data) {
        }
 
 #ifdef HAVE_LDAP
-       ctdl_vcard_to_ldap(msg);
+       ctdl_vcard_to_ldap(msg, V2L_WRITE);
 #endif
 
        CtdlFreeMessage(msg);
@@ -731,6 +731,9 @@ void vcard_delete_remove(char *room, long msgnum) {
                        */
                        vcard_extract_internet_addresses(msg,
                                                        CtdlDirectoryDelUser);
+#ifdef HAVE_LDAP
+                       ctdl_vcard_to_ldap(msg, V2L_DELETE);
+#endif
                }
                ptr = strchr((char *)ptr, '\n');
                if (ptr != NULL) ++ptr;