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 Chris Miller 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) behaving erratically.

Status
Not open for further replies.

rovils

Programmer
May 26, 2006
1
IN
Hi Friends,
I am facing a strange issue in one of my ASP programs. There are two versions of code. One which is working and one which is not.

This is the working code:

If Request.ServerVariables("AUTH_USER") = "" Then
Response.Status = "401 access denied"
response.write Response.Status
Response.End
End If


strUserID = Request.ServerVariables("AUTH_USER")

This returns me the user id which I can write.

Now the "Not working code"

strUserID = Request.ServerVariables("AUTH_USER")

If IsEmpty(strUserID) then
strUserID = Request.QueryString("UserID")
End If

Now , I am not able to understand why the first snippet of code is working and not the second one. The observation is whenver I am using the "If Request.ServerVariables("AUTH_USER") = "" Then" line in the code, I start getting Auth_User values. Else it simply does not return anything. Can someone enlighten me on this.

Thanks a lot.

Rovils
 
from an online source:

Code:
Try unticking "Integrated Windows Authentication" in the same area where you untick anynomous access.

MS seems to think that this is the only solution:
SYMPTOMS
Accessing the Request.ServerVariables("LOGON_USER") variable from Active Server Pages (ASP) returns an empty string. 

CAUSE
The LOGON_USER variable is not populated if the ASP page is accessed using Allow Anonymous security. 

In order for the LOGON_USER variable to be populated, the user must be authenticated using either Basic or NT Challenge/Response security.

-DNG
 
In your second (non-working) code, it is not empty. It may not have a value, but that would make it an empty string, not empty. You can look at the definition of the isEmpty function at this site for more information.

I would just continue to use the same test and see if the value = "".

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
First you aren't comparing apples to apples... an empty string is not necessarily equivilant to an empty unitialized variable.

Also be aware that if IE gets a "401 Access Denied" in response to an HTTP request for which it did not send credentials, it will automagically resend the request using the credentials of the current user.

It may be the case that the first piece of code runs, hits the 401, then IE resubmits and the page runs again and gets through the second time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top