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