Update seafile-ldap.py

This commit is contained in:
2021-10-21 16:53:33 -04:00
parent d213709436
commit 5d15c77cd5

View File

@@ -8,6 +8,7 @@ import argparse
import os
import requests
import urllib3
import json
def request(resource, seafile, method='GET', data=None):
if data is None:
@@ -97,11 +98,13 @@ logger.debug("Bind successful.")
logger.debug("Searching for users that have a email address, are enabled, and in the {} group.".format(config['LDAP SERVER']['seafileGroupDN']))
ldap.search(config['LDAP SERVER']['groupBaseDN'], '(&(mail=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(memberof={0}))'.format(config['LDAP SERVER']['seafileGroupDN']), attributes=['*'])
logger.debug("Found {0} users.".format(len(ldap.entries)))
for user in ldap.entries:
logger.debug("User: {0} - Email: {1} - UserDN: {1}".format(user.name, user.mail, user.distinguishedName))
seafileUsers = request('admin/search-user/?query=@johnhgaunt.com', seafile)['response']
ADusers = ldap.entries
for user in ADusers:
logger.debug("User: {0} - Email: {1} - UserDN: {2}".format(user.name, user.mail, user.distinguishedName))
seafileUsers = request('admin/search-user/?query=@johnhgaunt.com', seafile)['response']['user_list']
for user in seafileUsers:
logger.debug("User: {0} - Email: {1} - isActive: {2}".format(user['name'], user['email'], user['is_active']))
#print(ldap.entries[0].distinguishedName)
exit()
#Create a connection object, and bind with the given DN and password.