Return to Snippet

Revision: 4913
at January 28, 2008 17:04 by rengber

Initial Code
private string GetUserName()
        string retVal = string.Empty;
        //Pull the username out of the domain\user string.  
        retVal = Page.User.Identity.Name.Split('\\')[1]; 
        DirectoryEntry userEntry = new DirectoryEntry("WinNT://" + userName +",User");
        retVal = (string)userEntry.Properties["fullname"].Value;
        return retVal; 

Initial URL

Initial Description
Typically won't work if the ASP.Net service identity (in the machine.config ProcessModel section) is a local account.

Initial Title
ASP.Net Code to Get an Active Directory User Name from the Integrated Authentication Principal Name

Initial Tags
security, aspnet

Initial Language