14 lines
541 B
Python
14 lines
541 B
Python
import ldap
|
|
|
|
LDAP_SERVER = 'ldap://192.168.86.87'
|
|
BASE_DN = 'dc=acme,dc=local' # base dn to search in
|
|
LDAP_LOGIN = 'Administrator'
|
|
LDAP_PASSWORD = 'qwerty-asdf-1234'
|
|
OBJECT_TO_SEARCH = 'userPrincipalName=Administrator@acme.local'
|
|
ATTRIBUTES_TO_SEARCH = ['memberOf']
|
|
|
|
connect = ldap.initialize(LDAP_SERVER)
|
|
connect.set_option(ldap.OPT_REFERRALS, 0) # to search the object and all its descendants
|
|
connect.simple_bind_s(LDAP_LOGIN, LDAP_PASSWORD)
|
|
result = connect.search_s(BASE_DN, ldap.SCOPE_SUBTREE, OBJECT_TO_SEARCH, ATTRIBUTES_TO_SEARCH)
|