Py3 ldap3 Module not returning SAMAccountName attribute

Viewed 62

I am trying to put together a self service portal so users can unlock their accounts in Active Directory, currently running into an issue where ldap3 is not exposing the samaccountname attribute, it returns several attribs, just not the sam. This is what I have so far, if anyone has a snippet that shows how to use ldap3 to query an Active Directory ldap instance for a smaccountname it would be much appreciated.

python3
import ldap3
from ldap3 import Server, Connection, AUTO_BIND_NO_TLS, SUBTREE, BASE, ALL_ATTRIBUTES, ObjectDef, AttrDef, Reader, Entry, Attribute
import ssl
tls_configuration = Tls(validate=ssl.CERT_NONE, version=ssl.PROTOCOL_TLSv1


conn = Connection(Server('SERVER', port=389, use_ssl=False),
            auto_bind=AUTO_BIND_NO_TLS, user='CN=USER,DC=DOMAIN,DC=local',
            password='PWD')
            
conn.search(search_base='OU=Tier_1_Thycotic_User_Accounts,OU=Accounts,OU=Tier 1,OU=Admin,DC=Q2DC,DC=local', search_filter='(objectCategory=person)', search_scope=SUBTREE,attributes = ['sAMAAccountName'], size_limit=0) 
0 Answers
Related