python-ldap

ldap3 python search members of a group and retrieve their sAMAcountName (NT Username)

ldap3 python search members of a group and retrieve their sAMAcountName (NT Username) Question: I retrieve members of a group and their sAMAccountName (NT Accounts) I run the following code takes from: ldap3 python search members of a group and retrieve their sAMAcountName (Active Directory) I’m getting user name as output but after few I’m …

Total answers: 1

Why does python-ldap code raise the Exception ldap.REFERRAL?

Why does python-ldap code raise the Exception ldap.REFERRAL? Question: I’m trying to use the python-ldap library to connect to an Active Directory Server. I’m using the code found in this link. The following code works correctly: con = ldap.initialize(uri, bytes_mode=False) con.protocol_version = ldap.VERSION3 con.set_option(ldap.OPT_REFERRALS, 0) # required for AD authentication con.simple_bind_s(bindDN, bindPW) print("Authentication success!") With …

Total answers: 1

Can returned attributes be forced into lowercase

Can returned attributes be forced into lowercase Question: Changes on our LDAP Server have changed the case of the attributes returned from search. For example, "mailroutingaddress" is now "mailRoutingAddress". The searches themselves are case insensitive, but the python code processing the returned ldap object is attempting to reference attributes in all lower case and failing. …

Total answers: 2

LDAP search with username as variable

LDAP search with username as variable Question: I am using the Python-LDAP module and trying to make a query on the logged in user. The username will be passed into the query. When I simply type the username in as a string my results come out correctly. But if I try to pass the (username) …

Total answers: 4

How should I escape ldap special characters?

How should I escape ldap special characters? Question: I’m using python-ldap to query Active Directory I have this DN CN=Whalen, Sean,OU=Users,OU=Users and Groups,DC=example,DC=net That works fine as a base in a query, but if I try to use it in a search filter like this (&(objectClass=group)(memberof:1.2.840.113556.1.4.1941:=CN=Whalen, Sean,OU=Users,OU=Users and Groups,DC=example,DC=net)) I get a Bad search filter …

Total answers: 2

Search deleted users/groups in AD with python-ldap

Search deleted users/groups in AD with python-ldap Question: If you delete an user or group in windows AD, it will in “DElETE objects”. I want to use python ldap lib to get them. Code: <code> import ldap uri = “ldap://10.64.74.17” user = “XXXXXXXXXX” password = “XXXXXXXXXXXX” ldap.set_option(ldap.OPT_REFERRALS, 0) ldap.set_option(ldap.OPT_NETWORK_TIMEOUT, 5) ldap.protocol_version = 3 ldapClient = …

Total answers: 1