Problems to get active directory guid current user in a windows service
When I've created a code to get a active directory guid by current user in
windows service
public static String getUserAdGuid(string userName) {
DirectorySearcher searcher = new DirectorySearcher();
searcher.Filter = "(&(objectClass=user)(sAMAccountName=" +
userName + "))";
SearchResult searchResult = searcher.FindOne();
DirectoryEntry entry = searchResult.GetDirectoryEntry();
Guid objectGuid = new Guid(entry.NativeGuid);
return objectGuid.ToString();
}</code> <br />
unfortunately not work rigth, I've checked and this result is not guid by
current active directory user.
Somebody can help me about this?
No comments:
Post a Comment