KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to get a user's email address in AD without success. String account = userAccount.Replace(@"Domain\", ""); DirectoryEntry entry = new DirectoryEntry(); try { DirectorySearcher search = new DirectorySearcher(entry); search.PropertiesToLoad.Add("mail"); // e-mail addressead SearchResult result = search.FindOne(); if (result != null) { return result.Properties["mail"][0].ToString(); } else { return "Unknown User"; } } catch (Exception ex) { return ex.Message; } Can anyone see the issue or point in the right direction?
Tags (comma-separated)
Save Edits
Cancel