Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows 2000 login name? 1

Status
Not open for further replies.

adonet

MIS
May 4, 2004
312
US
I try to get Windows 2000 user login ID using bellow code:

System.Security.Principal.WindowsIdentity.GetCurrent.Name

this only gave me COMPUTER_NAME/ASPNET. What is wrong?

What I need is COMPUTER_NAME/USER_LOGIN_ID. Can someone help me?
 
This is an extraordinary coincidence: I have asked the same question. My thread is directly above yours (thread855-928083). Perhaps you could experiment with the code in my last post. I think that I'm really close to the answer.
 
When running an asp.net application, the app runs under the MACHINENAME\ASPNET user account. As far as I know, there is no way to get your visiting user's Windows user name (think... it would be a pretty big security risk), unless you're forcing a login using Windows authentication (and in that case, you would have to set up user accounts on your server for each new user).

You can, however, get information such as IP address, browser and browser version, etc. with the Request.ServerVaribles function (see for more info)

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
In iis you need to enable Integrated Windows Identity. Then in the config file add <identity impersonate="true" />
 
...That's what I meant with "Windows Authentication" :)

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Well, I'm happy to get a star, but the problem persists for me!

On the same server, we have dozens of classic asp pages that use Request.ServerVariables("AUTH_USER"). They function normally. So we know that the IIS settings are okay. I set up this test:


dim x as string
x= [something]
labelx.text= x

For the text within brackets, I have tried each of these variations~

User.Identity.Name.ToString()
User.Identity.Name
context.User.Identity.Name.ToString()
HttpContext.Current.Request.UserHostName.ToString() *
HttpContext.Current.User.Identity.Name.ToString()
HttpContext.Current.Request.UserAgent.ToString *
ClientID.ToString() **
Request.ServerVariables("remote_user")
Request.ServerVariables("LOGON_USER")
Request.ServerVariables("AUTH_USER").ToString()
Request.ServerVariables("AUTH_USER")

I built each of these without causing an error. Most did not return anything. The variations with one asterisk returned something other than the username. The variation with two asterisks failed when I ran it.

I am putting the code into the .aspx page's page_load event.










 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top