What is the NativeGuid in DirectoryEntry when queried through the WinNT provider?
I am writing an application that I want to work with both Active Directory and local users and groups. I thought I could use the NativeGuid property of DirectoryEntry as a unique identifier that was obtained using the WinNT provider against LocalHost. However, using the following code in LinqPad , I get the same NativeGuid for both entries. Active Dirctory query with LDAP provider gives unique results, but now I'm not sure.
System.DirectoryServices.DirectoryEntry localuserde =
new System.DirectoryServices.DirectoryEntry("WinNT://localhost/localuser");
localuserde.NativeGuid.Dump("localUser Guid");
System.DirectoryServices.DirectoryEntry adminde =
new System.DirectoryServices.DirectoryEntry("WinNT://localhost/administrator");
adminde.NativeGuid.Dump("administrator Guid");
Can someone please explain what the NativeGuid represents when using the WinNT provider and is there a good alternative for uniqueId or SID - a better choice?
To run the above in LinqPad press F4 and add System.DirectoryServices.dll to the assembly list. Then make sure localuser either exists or changes the name to a local user on the system. Then press F5.
Thanks,
Shane Holder
a source to share
I think the SID is probably the best fit for any user and group related scenario. There is really no other unique identifier - especially not with the WinNT provider.
Read more about WinNT vs. LDAP and excellent Excel reference sheets on what properties each of these providers actually exposes (and what their names are), visit Richard Mueller's Hilltop Lab . Richard is an ADSI MVP and has great content for anyone interested in Active Directory and LDAP.
Mark
a source to share