Monday, September 17, 2007

Getting the login name of a logged in user

http://forums.asp.net/t/1045923.aspx
string windowsLogin = Page.User.Identity.Name;
//Normally if the domain is present you get a string like DOMAINNAME\username, remove the domain
int hasDomain = windowsLogin.IndexOf(@"\");
if (hasDomain > 0)
{
windowsLogin = windowsLogin.Remove(0, hasDomain + 1);
} //end if


No comments: