From f55c05a5751457a53aeac5f5d762d33f88357037 Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Tue, 2 Nov 2021 15:26:50 -0400 Subject: [PATCH] only disable account if it isn't --- seafile-ldap.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/seafile-ldap.py b/seafile-ldap.py index 37c5e59..0211cdb 100644 --- a/seafile-ldap.py +++ b/seafile-ldap.py @@ -215,6 +215,9 @@ for ldapUser in ldapUsers: # Loop through the sql ldap users and disable those not in the ldap list for sqlLDAPuser in sqlLDAPusers: + if sqlLDAPuser[4]: + logger.debug("User {0} is already disabled in Seafile".format(sqlLDAPuser[1])) + continue logger.debug("Searching for user {0} that has an email address, are enabled, and in the {1} group.".format(sqlLDAPuser[1], ldapFilter)) ldap.search(ldapBase, '(&(mail={0})(!(userAccountControl:1.2.840.113556.1.4.803:=2))({1}))'.format(sqlLDAPuser[1], ldapFilter), attributes=['*']) count = len(ldap.entries)