diff --git a/seafile-ldap.py b/seafile-ldap.py index aca01f0..b257214 100644 --- a/seafile-ldap.py +++ b/seafile-ldap.py @@ -163,18 +163,12 @@ logger.debug("Starting SQL query for LDAPUsers") query = ("SELECT * FROM LDAPUsers") logger.debug("Query: {0}".format(query)) cursor.execute(query) -results = cursor.fetchall() +sqlLDAPusers = cursor.fetchall() logger.debug("Found {0} SQL LDAP users".format(cursor.rowcount)) -sqlLDAPusers = [] -for user in results: - temp = [] +for user in sqlLDAPusers: logger.debug("User: {0} - Active: {1}".format(user[1], bool(user[4]))) - temp['email'] = user[1] - temp['is_active'] = user[4] - sqlLDAPusers.append(temp) logger.debug("Finished SQL query for LDAPUsers") -print(sqlLDAPusers) -exit() + # Loop through the ldap users and make sure they are in the sql ldap users table # if they are not in the sql table, insert a new row to add them # if they are disabled in the sql table, enable them @@ -182,6 +176,7 @@ set_sqlLDAPusers = set(sqlLDAPusers) for user in ldapUsers: if [item for item in sqlLDAPusers if user.mail in item]: logger.debug("LDAP User {0} is already in the SQL Table".format(user.mail)) + logger.debug("item {0} is already in the SQL Table".format(item)) #seafileUsers = request('admin/search-user/?query=@johnhgaunt.com', seafileURL, seafileToken)['response']['user_list'] #for user in seafileUsers: