I log in to Active Directory, then I want to list my own group memberships with Python ldap3 library.
server = Server('server.company.local', get_info=ALL)
conn = Connection(server, user="company\\user", password="password", authentication=NTLM, auto_bind=True)
print(conn.extend.standard.who_am_i())
This code only shows user name (like whoami
cmd command), but i want to list my groups (like whoami /groups
command).
Unfortunately I dont have the rights to make different searches on the Domain controller, thats why (perhaps) the following code returns empty string:
conn.search("dc=name,dc=company,dc=local","(&(sAMAccountName={}))".format("company\\myusername")
,attributes=['memberOf'])
How can i list my own group membership, like whoami /groups
does?