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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request.ServerVariables("AUTH_USER")

Status
Not open for further replies.

OhioSteve

MIS
Joined
Mar 12, 2002
Messages
1,352
Location
US
Our shop makes applications for the company's intranet. In classic asp, we used this to obtain a user's identity~


Request.ServerVariables("AUTH_USER")

Now we are switching to asp.Net. I have tried Request.ServerVariables("AUTH_USER") in aspx pages, and it fails.

The web.config file DOES contain~

<authentication mode="Windows" />

and it ALSO contains

<authorization>
<allow users="*" /> <!-- Allow all users -->

So why doesn't it work?!?!?
 
Try User.Identity.Name. Remember that Integrated Windows Authentication has to be turned on in IIS for that site/virtual directory, too

[pipe]
 
Actually, I have already tried that.

I have a label on the page called labelx. Its normal text property is "label". In the page's load event, I added this code~

'attempt to get user ID
If User.Identity.IsAuthenticated Then
Labelx.Text = User.Identity.Name
Else
Labelx.Text = "No user identity available."
End If

When I loaded the form, labelx was blank. I also tried user.identity.name.tostring(). When I loaded the page the label displayed the value "label" (which is its normal value).

Later I tried omitting the "isauthenticated" test. This did not help :(
 
Steve,
Make sure you have the Enable anonymous access is Not checked and Inegrated windows authentication is the only checked box

the code I am using is almost identical to yours and its working for me

if that doesnt work restart IIS

Good luck


Note:Copying and Pasting is NoT Creativity.
What would you attempt to accomplish if you knew you would not fail?
 
<authorization>
<allow users="*" />

means all user are allowed. you should switch to
<authorization>
<deny users="?" />
<allow users="*" />

to allow only the authorised users.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top