/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/// <summary> /// Gets the user AD email address from Principal Context. /// </summary> /// <param name="username">The username.</param> /// <returns>Returns the email address of AD user, and an empty string if not found.</returns> public static string GetADUserEmailAddress(string username) { using (UserPrincipal up = UserPrincipal.FindByIdentity(pctx, username)) { return up != null && !String.IsNullOrEmpty(up.EmailAddress) ? up.EmailAddress : string.Empty; } } }