Add more logging
This commit is contained in:
parent
7e2a4ba673
commit
5e1d62caf3
|
@ -194,6 +194,7 @@ def add_to_group(groupname, username):
|
||||||
ldap_conn.modify_s(group_dn, mod_acct)
|
ldap_conn.modify_s(group_dn, mod_acct)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
logger.info('Already a member, skipping')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
@ -214,6 +215,7 @@ def remove_from_group(groupname, username):
|
||||||
ldap_conn.modify_s(group_dn, mod_acct)
|
ldap_conn.modify_s(group_dn, mod_acct)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
logger.info('Not a member, skipping')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
@ -243,6 +245,7 @@ def is_member(groupname, username):
|
||||||
'''
|
'''
|
||||||
ldap_conn = init_ldap()
|
ldap_conn = init_ldap()
|
||||||
try:
|
try:
|
||||||
|
logger.info('Checking group membership...')
|
||||||
ldap_conn.simple_bind_s(secrets.LDAP_USERNAME, secrets.LDAP_PASSWORD)
|
ldap_conn.simple_bind_s(secrets.LDAP_USERNAME, secrets.LDAP_PASSWORD)
|
||||||
group_dn = find_group(groupname)
|
group_dn = find_group(groupname)
|
||||||
user_dn = find_user(username).encode()
|
user_dn = find_user(username).encode()
|
||||||
|
@ -308,6 +311,6 @@ if __name__ == '__main__':
|
||||||
#print(list_group("newgroup"))
|
#print(list_group("newgroup"))
|
||||||
#print(dump_users())
|
#print(dump_users())
|
||||||
|
|
||||||
users = list_group('Laser Users')
|
#users = list_group('Laser Users')
|
||||||
import json
|
#import json
|
||||||
print(json.dumps(users, indent=4))
|
#print(json.dumps(users, indent=4))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user