Greetings,
This is the scenario: I have a web application developed in ASP.NET with VB.NET. The application will be accesed from both, intranet and extranet. The idea is that if the user is within the intranet the Windows NT account is checked in the DB (the user name which is logged in), otherwise (if the user is not within the intranet) the user is prompted to a login-password page.
So, the problem is getting the Windows NT current user name logged in.
In the web config i have:
<authentication mode="Windows"/>
Here is what i have tried:
Dim username1 As String = System.Security.Principal.WindowsIdentity.GetCurrent.Name
Dim username2 As String = Environment.UserName
Dim username3 As String = HttpContext.Current.User.Identity.Name
Dim username4 As String = Request.ServerVariables("AUTH_USER")
Dim username5 As String = Request.ServerVariables("REMOTE_USER")
The output for the variables is the following:
In the development enviroment, using Visual Studio 2005 and the ASP.NET Development Server
username1 = FERNANDO-VM\Fernando
username2 = Fernando
username3 = FERNANDO-VM\Fernando
username4 = FERNANDO-VM\Fernando
username5 = FERNANDO-VM\Fernando
In the prod environment, using IE and IIS
username1 = FERNANDO-VM\IUSR_FERNANDO-VM
username2 = IUSR_FERNANDO-VM
username3 = (empty)
username4 = (empty)
username5 = (empty)
The desired outputs are the ones that shows the development environment, from which i can extract the windows current user name (Fernando).
Do i have a concept error? how could i get the windows user name???
Thank you in advance,
Fernando
Because everything is possible...