facing a problem

  • Thread starter Thread starter hussein_hariri
  • Start date Start date
H

hussein_hariri

hello
i have started working bye ASP.net but i'm facing a small
problem. i'm trying to get the name of the user who
logedon to the opersating system , i got the computer
name, server name, domain name, and the name of the user
who started the studio.net { ASPNET }. but the one who
logged on to the operating system i was not able to so any
one can help me?
thank you for responding
 
You can get the name of the person logged on to the application with
ASP.NET, but that does not necessarily mean the person logged onto the OS,
as a person can type in a different account when the Windows Authentication
logon pops up. If you need that person, you can use:

private string GetUserNumber()
{
// Set up character(s) to split on
char[] splitChar = @"\".ToCharArray();

// Split user to get user ID only
string[] user = Request.ServerVariables["LOGON_USER"].Split(splitChar);
int userArrayMax = user.Length-1;


// This is designed for lookup of user
return user[userArrayMax];
}

This returns the string of the account logged into the ASP.NET app. The
problem here, as stated, is the person logged onto the computer and the
person logged into the app can be different.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
To display the user logged into the OS, See that the Anonymous user option in the IIS is off and read this value
"HttpContext.Current.User.Identity.Name"
 
Back
Top