Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I seem to be having an issue getting the username of the user visiting my site. This is an intranet site and will be cross domain.

What I need to do is authenticate the user in Active Directory. I know how to do this in Active Directory but what I can't do is get the username that I want to authenticate. The client does not want to use a login form, so I set my authentication type in web.config to 'Windows' and to get the user I have tried:

<br />
Request.ServerVariables.Get("AUTH_USER")<br />
or <br />
Request.ServerVariables.Get("LOGON_USER")<br />


both provide me with my username while running local. But when I post this on the our Test server I get NETWORK_SERVICES.

Can someone tell me another way of getting the correct user? Would this be where setting IIS on the test server to Windows Authentication would come in at? I have not done this yet until I figure this first part out.

Thanks
Posted

Yes, you cant use "Auth_User" or Logon_User to get the appropriate username. You need to search using DirectoryServices.

Check this link :
http://forums.asp.net/t/1066136.aspx[^]

I think this is what exactly you are looking for. :rose:
 
Share this answer
 
Comments
DeepToot 30-Jun-10 17:42pm    
Reason for my vote of 5
Perfect answer
Excellent that is what I was looking for!

<br />
HttpContext.Current.User.Identity.Name<br />


was my missing link. Love the easy fixes.

Thank you for the time and response.
 
Share this answer
 
Comments
Abhishek Sur 30-Jun-10 18:10pm    
Thank you so much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900