Active Directory - Determining unique ID of a domain
Hi I am wondering if there is a way of uniquely identifying a network domain using Active Directory.
For example, if I go to work at company A and its domain is called MyDomain and the开发者_如何学Cn I go to company B and it's domain is also called MyDomain, is there some way of testing for uniqueness using Active Directory? ie. is there a GUID or some other unique property that will not change through the life of the domain, that I can find using AD? Thanks for any advice!
As for any AD object, there is an objectGuid
property on the domain level entry which remains unchanged, I believe. You can read it out like this:
DirectoryEntry domainEntry = new DirectoryEntry("LDAP://dc=yourcompany,dc=com");
byte[] guid = (byte[])domainEntry.Properties["objectGuid"][0];
Guid domainGuid = new Guid(guid);
精彩评论