]> code.citadel.org Git - citadel.git/commitdiff
* Reworked vCard etc. functions for addition of new vCard data to LDAP
authorArt Cancro <ajc@citadel.org>
Sun, 18 Jan 2004 21:04:40 +0000 (21:04 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 18 Jan 2004 21:04:40 +0000 (21:04 +0000)
citadel/ChangeLog
citadel/serv_ldap.c
citadel/serv_ldap.h [new file with mode: 0644]
citadel/serv_network.c
citadel/serv_vcard.c
citadel/server.h

index bb35ff26977a6e2ebbd628f204658ff17c5d2b24..4214a736e5b6a114a62de887660daf962aec9135 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 614.6  2004/01/18 21:04:40  ajc
+ * Reworked vCard etc. functions for addition of new vCard data to LDAP
+
  Revision 614.5  2004/01/17 22:57:54  ajc
  * Added "Base DN" "Bind DN" and "Bind DN password" config options
  * serv_ldap.c: added.  (New module implementing the LDAP Connector)
@@ -5230,3 +5233,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 d97e64cea0e6810fc5d78884e01cde507556213c..c9892fe944096717557d76f90c6a606a2aadddfe 100644 (file)
@@ -40,6 +40,8 @@
 #include "policy.h"
 #include "database.h"
 #include "msgbase.h"
+#include "serv_ldap.h"
+#include "vcard.h"
 
 #ifdef HAVE_LDAP
 
@@ -93,6 +95,38 @@ void CtdlConnectToLdap(void) {
 }
 
 
+
+
+/*
+ * Write (add, or change if already exists) a directory entry to the
+ * LDAP server, based on the information supplied in a vCard.
+ */
+void ctdl_vcard_to_ldap(struct CtdlMessage *msg) {
+       struct vCard *v = NULL;
+
+       char this_dn[SIZ];
+
+       if (msg == NULL) return;
+       if (msg->cm_fields['M'] == NULL) return;
+       if (msg->cm_fields['A'] == NULL) return;
+       if (msg->cm_fields['N'] == NULL) return;
+
+       sprintf(this_dn, "cn=%s,ou=%s,%s",
+               msg->cm_fields['A'],
+               msg->cm_fields['N'],
+               config.c_ldap_base_dn
+       );
+
+       lprintf(9, "this_dn: <%s>\n", this_dn);
+
+       v = vcard_load(msg->cm_fields['M']);
+
+       vcard_free(v);
+}
+
+
+
+
 /*
  * Initialize the LDAP connector module ... or don't, if we don't have LDAP.
  */
diff --git a/citadel/serv_ldap.h b/citadel/serv_ldap.h
new file mode 100644 (file)
index 0000000..b4a9fb2
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * $Id$
+ *
+ */
+
+#ifdef HAVE_LDAP
+
+void ctdl_vcard_to_ldap(struct CtdlMessage *msg);
+
+
+#endif /* HAVE_LDAP */
index 776bd009d9820baa6a457d4b0de342ba5db15478..2365e4a150cb4be7debcbe945a5e53f7cf286c5e 100644 (file)
@@ -1181,7 +1181,6 @@ void network_process_file(char *filename) {
        long msgcur = 0L;
        int ch;
 
-       lprintf(7, "network: processing <%s>\n", filename);
 
        fp = fopen(filename, "rb");
        if (fp == NULL) {
@@ -1190,6 +1189,8 @@ void network_process_file(char *filename) {
                return;
        }
 
+       lprintf(5, "network: processing <%s>\n", filename);
+
        /* Look for messages in the data stream and break them out */
        while (ch = getc(fp), ch >= 0) {
        
@@ -1226,7 +1227,8 @@ void network_do_spoolin(void) {
        if (dp == NULL) return;
 
        while (d = readdir(dp), d != NULL) {
-               snprintf(filename, sizeof filename, "./network/spoolin/%s", d->d_name);
+               snprintf(filename, sizeof filename,
+                       "./network/spoolin/%s", d->d_name);
                network_process_file(filename);
        }
 
index 443783172a31781ffeb00da5022a9802a9373a32..9e2b3381585086e2b7f98a98c3062563163c86cb 100644 (file)
@@ -63,6 +63,7 @@
 #include "internet_addressing.h"
 #include "tools.h"
 #include "vcard.h"
+#include "serv_ldap.h"
 
 struct vcard_internal_info {
        long msgnum;
@@ -172,6 +173,10 @@ void vcard_add_to_directory(long msgnum, void *data) {
                vcard_extract_internet_addresses(msg, vcard_directory_add_user);
        }
 
+#ifdef HAVE_LDAP
+       ctdl_vcard_to_ldap(msg);
+#endif
+
        CtdlFreeMessage(msg);
 }
 
@@ -196,7 +201,7 @@ void cmd_igab(char *argbuf) {
         */
        CtdlDirectoryInit();
 
-        /* We want the last (and probably only) vcard in this room */
+        /* We want *all* vCards in this room */
         CtdlForEachMessage(MSGS_ALL, 0, "text/x-vcard",
                NULL, vcard_add_to_directory, NULL);
 
index 0886d8e94c4b0af6a4ed035735b5e03c2a9e4b60..a3073b5d618f01c6b27130ab3c61df4f84029779 100644 (file)
@@ -214,6 +214,7 @@ enum {
        S_DIRECTORY,
        S_NETCONFIGS,
        S_PUBLIC_CLIENTS,
+       S_LDAP,
        MAX_SEMAPHORES
 };