I have the DN of a user in Active Directory, I want to get the "NT style" domain\user from this. The sAMAccountname AD property gives me the user part, but what about the domain?
Thanks
active-directorydns
I have the DN of a user in Active Directory, I want to get the "NT style" domain\user from this. The sAMAccountname AD property gives me the user part, but what about the domain?
Thanks
Best Answer
You can get it by taking the last part of the user DN (
DC=domain,DC=local
) and addingCN=Partitions,CN=Configuration,
before.Then do a subtree search for
(&(nCName="DC=domain,DC=local")(nETBIOSName=*))
withCN=Partitions, CN=Configuration, DC=domain, DC=local
as the starting point; the entry you get back will have the NETBIOS name of the domain in thenETBIOSName
-attribute.