Hi,
I am trying to solve an intermittent error that I keep getting on one of the web applications that I have developed.
There is a check performed which gets the logon name of the current user to determine if the person is an administrator. The main part of this function is that it uses the request.servervariables("LOGON_USER"
call to find the name of the person that is logged on. In some cases it works fine and in other cases it does not, and a custom error message displays. When I refresh the page the error sometimes remains and at other time disappear.
Does anyone know what is causing this. I am really perplexed as to why this is the case.
Code is as follows:
Any pointers would help!
SonD
I am trying to solve an intermittent error that I keep getting on one of the web applications that I have developed.
There is a check performed which gets the logon name of the current user to determine if the person is an administrator. The main part of this function is that it uses the request.servervariables("LOGON_USER"
Does anyone know what is causing this. I am really perplexed as to why this is the case.
Code is as follows:
Code:
function GetNTUsername()
strUserName=Request.ServerVariables("logon_user")
for intLoop=1 to len(strUserName) ' remove the domain name from logon_user
if mid(strUserName, intLoop,1)="\" then
intSplitPos=intLoop
end if
next
GetNTUsername=UCase(Right(strUserName,Len(strUserName)-intSplitPos))
end function
'find out if our current user is an administrator
strThisUser=GetNTUserName
'Response.Write "logon_user: " & Request.ServerVariables("LOGON_USER") & "<BR><BR>"
'Response.Write "auth_user: " & Request.ServerVariables("AUTH_USER") & "<BR><BR>"
'Response.Write "strThisUser: " & strThisUser & "<BR><BR>"
strSQLTemp="Select * from TableName WHERE FieldName='" & strThisUser & "'"
call OpenDatabase
call CreateCommand
objCmdTemp.CommandText=strSQLTemp
set objRecIsAdmin=server.CreateObject("ADODB.Recordset")
objRecIsAdmin.Open objCmdTemp, , adOpenStatic, adLockOptimistic
if objRecIsAdmin.EOF then
blnIsAdmin=false
else
blnIsAdmin=true
end if
objRecIsAdmin.Close
set objRecIsAdmin=nothing
call CloseDatabase
Any pointers would help!
SonD