Update seafile-ldap.py
This commit is contained in:
@@ -8,6 +8,7 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
import urllib3
|
import urllib3
|
||||||
|
import json
|
||||||
|
|
||||||
def request(resource, seafile, method='GET', data=None):
|
def request(resource, seafile, method='GET', data=None):
|
||||||
if data is 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']))
|
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=['*'])
|
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)))
|
logger.debug("Found {0} users.".format(len(ldap.entries)))
|
||||||
for user in ldap.entries:
|
ADusers = ldap.entries
|
||||||
logger.debug("User: {0} - Email: {1} - UserDN: {1}".format(user.name, user.mail, user.distinguishedName))
|
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']
|
|
||||||
|
|
||||||
|
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)
|
#print(ldap.entries[0].distinguishedName)
|
||||||
exit()
|
exit()
|
||||||
#Create a connection object, and bind with the given DN and password.
|
#Create a connection object, and bind with the given DN and password.
|
||||||
|
|||||||
Reference in New Issue
Block a user