removed some debugs
[citadel.git] / citadel / ldap.c
index 349cadfe79cd5cb864d44f88f3cae9aea3fd93aa..5c54953c1a668da9df86c90a86933e32974586f1 100644 (file)
@@ -179,7 +179,7 @@ int CtdlTryUserLDAP(char *username, char *found_dn, int found_dn_size, char *ful
                NULL,                                           // clientctrls (none)
                &tv,                                            // timeout
                1,                                              // sizelimit (1 result max)
-               &search_result                                  // res
+               &search_result                                  // put the result here
        )));
 
        // Ignore the return value of ldap_search_ext_s().  Sometimes it returns an error even when
@@ -221,6 +221,7 @@ int CtdlTryUserLDAP(char *username, char *found_dn, int found_dn_size, char *ful
 }
 
 
+// This is an extension of CtdlTryPassword() which gets called when using LDAP authentication.
 int CtdlTryPasswordLDAP(char *user_dn, const char *password) {
        LDAP *ldserver = NULL;
        int i = (-1);
@@ -516,6 +517,14 @@ int extract_email_addresses_from_ldap(char *ldap_dn, char *emailaddrs) {
 }
 
 
+// Remember that a particular user exists in the Citadel database.
+// As we scan the LDAP tree we will remove users from this list when we find them.
+// At the end of the scan, any users remaining in this list are stale and should be deleted.
+void ldap_note_user_in_citadel(char *username, void *data) {
+       return;
+}
+
+
 // Scan LDAP for users and populate Citadel's user database with everyone
 //
 // POSIX schema:       All objects of class "inetOrgPerson"
@@ -530,11 +539,14 @@ void CtdlSynchronizeUsersFromLDAP(void) {
        struct timeval tv;
 
        if ((CtdlGetConfigInt("c_auth_mode") != AUTHMODE_LDAP) && (CtdlGetConfigInt("c_auth_mode") != AUTHMODE_LDAP_AD)) {
-               return;                                         // This site is not running LDAP.  Stop here.
+               return;                                         // If this site is not running LDAP, stop here.
        }
 
        syslog(LOG_INFO, "ldap: synchronizing Citadel user database from LDAP");
 
+       // first, scan the existing Citadel user list
+       // ForEachUser(ldap_note_user_in_citadel, NULL);        // FIXME finish this
+
        ldserver = ctdl_ldap_bind();
        if (!ldserver) return;
 
@@ -560,7 +572,7 @@ void CtdlSynchronizeUsersFromLDAP(void) {
                NULL,                                           // clientctrls (none)
                &tv,                                            // timeout
                INT_MAX,                                        // sizelimit (max)
-               &search_result                                  // result
+               &search_result                                  // put the result here
        )));
 
        // Ignore the return value of ldap_search_ext_s().  Sometimes it returns an error even when
@@ -573,7 +585,6 @@ void CtdlSynchronizeUsersFromLDAP(void) {
 
        syslog(LOG_DEBUG, "ldap: %d entries returned", ldap_count_entries(ldserver, search_result));
        for (entry=ldap_first_entry(ldserver, search_result); entry!=NULL; entry=ldap_next_entry(ldserver, entry)) {
-               TRACE;
                user_dn = ldap_get_dn(ldserver, entry);
                if (user_dn) {
                        syslog(LOG_DEBUG, "ldap: found %s", user_dn);
@@ -610,7 +621,6 @@ void CtdlSynchronizeUsersFromLDAP(void) {
                        }
                        ldap_memfree(user_dn);
                }
-               TRACE;
        }
 
        // free the results