Lots of LDAP changes.
authorDave West <davew@uncensored.citadel.org>
Sat, 6 Oct 2007 18:22:43 +0000 (18:22 +0000)
committerDave West <davew@uncensored.citadel.org>
Sat, 6 Oct 2007 18:22:43 +0000 (18:22 +0000)
The schema has changed every one will need to update to the new schema.
The dn has changed, you will need to delete all citadel entries from your
ldap and then do sendcommand IGAB.
A user with write permission to the GAB room can now add and edit entries
that do not refer to them or any other user.
Aides can now alter other users entries without it then becoming theirs.
Users can now update their personal vcard and have it reflected in the GAB
and ldap.

Remaining to do:
Delete and entry from GAB should delete it from ldap.
Editing a users GAB entry does not propogate back to the users vcard.
auth via ldap is coming so you might want to stay away from this for the moment.

citadel/modules/ldap/serv_ldap.c
citadel/modules/vcard/serv_vcard.c
citadel/openldap/citadel.schema

index 78343e05df5f2bcb5865800cc235235b11e47bc0..7e3634ec7eae12215fc2a4ada87b63f4d5010e6d 100644 (file)
@@ -295,28 +295,51 @@ int CtdlSaveLdapObject(char *cn, char *ou, void **object)
        if (ou == NULL) return -1;
        if (cn == NULL) return -1;
        
-       sprintf(this_dn, "cn=%s,ou=%s,%s", cn, ou, config.c_ldap_base_dn);
+       sprintf(this_dn, "euid=%s,ou=%s,%s", cn, ou, config.c_ldap_base_dn);
+       
+       lprintf(CTDL_INFO, "LDAP: Calling ldap_add_s() for dn of '%s'\n", this_dn);
 
        /* The last attribute must be a NULL one. */
        attrs = (LDAPMod **)*object;
        if (attrs)
        {
                while (attrs[num_attrs])
+               {
+                       count = 0;
+                       while (attrs[num_attrs]->mod_values[count])
+                       {
+                               lprintf (CTDL_DEBUG, "LDAP: attribute %d, value %d = \'%s=%s\'\n", num_attrs, count, attrs[num_attrs]->mod_type, attrs[num_attrs]->mod_values[count]);
+                               count++;
+                       }
                        num_attrs++;
+               }
+       }
+       else
+       {
+               lprintf(CTDL_ERR, "LDAP: no attributes in CtdlSaveLdapObject\n");
+               return -1;
        }
-       
-       lprintf(CTDL_DEBUG, "LDAP: Calling ldap_add_s() for '%s'\n", this_dn);
        
        begin_critical_section(S_LDAP);
        i = ldap_add_s(dirserver, this_dn, attrs);
        end_critical_section(S_LDAP);
+       
+       if (i == LDAP_SERVER_DOWN)
+       {       // failed to connect so try to re init the connection
+               serv_ldap_cleanup();
+               CtdlConnectToLdap();
+               // And try the save again.
+               begin_critical_section(S_LDAP);
+               i = ldap_add_s(dirserver, this_dn, attrs);
+               end_critical_section(S_LDAP);
+       }
 
        /* If the entry already exists, repopulate it instead */
        if (i == LDAP_ALREADY_EXISTS) {
                for (j=0; j<(num_attrs); ++j) {
                        attrs[j]->mod_op = LDAP_MOD_REPLACE;
                }
-               lprintf(CTDL_DEBUG, "LDAP: Calling ldap_modify_s() for '%s'\n", this_dn);
+               lprintf(CTDL_INFO, "LDAP: Calling ldap_modify_s() for dn of '%s'\n", this_dn);
                begin_critical_section(S_LDAP);
                i = ldap_modify_s(dirserver, this_dn, attrs);
                end_critical_section(S_LDAP);
index 066fc72534780a57216584f45b17e52faf695238..7528db3c78a5a6def73e967a0b64f9c1e7a784d8 100644 (file)
@@ -156,6 +156,7 @@ void ctdl_vcard_to_directory(struct CtdlMessage *msg, int op) {
        char state[3];
        char zipcode[10];
        char calFBURL[256];
+       char *EUID=NULL;
 
        if (msg == NULL) return;
        if (msg->cm_fields['M'] == NULL) return;
@@ -300,17 +301,21 @@ void ctdl_vcard_to_directory(struct CtdlMessage *msg, int op) {
        /* Add a "cn" (Common Name) attribute based on the user's screen name,
         * but only there was no 'fn' (full name) property in the vCard 
         */
-       if (!have_cn) {
+       if (!have_cn)
                (void) CtdlDoDirectoryServiceFunc("cn", msg->cm_fields['A'], &objectlist, "ldap", DIRECTORY_ATTRIB_ADD);
-       }
 
        /* Add a "calFBURL" attribute if a calendar free/busy URL exists */
        if (!IsEmptyStr(calFBURL)) {
                (void) CtdlDoDirectoryServiceFunc("calFBURL", calFBURL, &objectlist, "ldap", DIRECTORY_ATTRIB_ADD);
        }
        
-       (void) CtdlDoDirectoryServiceFunc(msg->cm_fields['A'], msg->cm_fields['N'], &objectlist, "ldap", DIRECTORY_SAVE_OBJECT);
-
+       // Add this messages EUID as the primary key for this entry.
+       EUID=msg->cm_fields['E'];
+       (void) CtdlDoDirectoryServiceFunc("euid", EUID, &objectlist, "ldap", DIRECTORY_ATTRIB_ADD);
+       
+       
+       (void) CtdlDoDirectoryServiceFunc(EUID, msg->cm_fields['N'], &objectlist, "ldap", DIRECTORY_SAVE_OBJECT);
+       
        (void) CtdlDoDirectoryServiceFunc(NULL, NULL, &objectlist, "ldap", DIRECTORY_FREE_OBJECT);
        lprintf(CTDL_DEBUG, "LDAP write operation complete.\n");
 }
index 938f166ac1bb226cb34df933c31a3093adb53543..3b928690c31b6764fe72d67e84c229b59d03db7c 100644 (file)
@@ -40,6 +40,13 @@ attributetype ( 1.3.6.1.4.1.25404.1.1.1
   SUBSTR caseIgnoreIA5SubstringsMatch
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
 
+# euid used to provide unique identifier for GAB entries
+attributetype ( 1.3.6.1.4.1.25404.1.1.2
+  NAME 'euid'
+  DESC 'unique GAB entry'
+  EQUALITY caseExactMatch
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{256} )
+
 ##########################
 # citadel object classes #
 ##########################
@@ -53,6 +60,7 @@ objectclass ( 1.3.6.1.4.1.25404.1.2.1
   DESC 'Citadel Internet Organizational Person'
   SUP inetOrgPerson
   STRUCTURAL
+  MUST ( euid )
   MAY ( c $
       alias $
       calFBURL )