CurrentUserName
The CurrentUserName
returns the username of the currently authenticated user when using Basic Authentication.
When using cookie-based protection, use
CookieCurrentUsername
or refer to
cookieSWValue
as appropriate.
PLEASE READ THE
NOTE BELOW.
Syntax
CurrentUserName(SERVER_NAME, SCRIPT_NAME, HTTP_AUTHORIZATION)
Parameters
-
SERVER_NAME
-
Server name, see example
-
SCRIPT_NAME
-
Script name, see example
-
HTTP_AUTHORIZATION
-
HTTP Authorization, see example
Return Values
Returns the username of the currently authenticated user. The
return value is empty if there is none.
Other Functions
In Version 4.7c and above,
<% currentUser = AuthX.Base64UserName(Request.ServerVariables("HTTP_AUTHORIZATION")) %>
and
<% currentPassword = AuthX.Base64Password(Request.ServerVariables("HTTP_AUTHORIZATION")) %>
are also available.
Note - IMPORTANT - READ THIS!!!
In IIS4 and above, the HTTP_AUTHORIZATION value may not be returned correctly by
IIS.
In MMC, select the directory in which the ASP page
calling this function resides.
If Basic (Clear Text) is off, and NTCR (Integrated Windows Authentication in Windows 2000) is
on, then HTTP_AUTHORIZATION
will not return the correct value.
This problem did not occur in IIS3. Microsoft bug Case Number is SR X980 2166010 644.
Recommended workaround is to
-
turn Basic (Clear Text) off and NTCR (Integrated Windows Authentication in Windows 2000) off for that directory.
Make sure that Allow Anonymous is checked.
In AuthentiX/WebQuota 5.1a and above, there is an alternative option:
(2/21/00)
In the AuthentiX Options dialog, check the checkbox labelled:
"Push through HTTP_AUTHORIZATION as HTTP_AUTHXAUTHORIZATION
even if NTCR is on."
Then use
Request.ServerVariables("HTTP_AUTHXAUTHORIZATION")
instead of
Request.ServerVariables("HTTP_AUTHORIZATION")
in the examples given.
Also, see here.
Example
<%
usingAuthentiXStandard = true
if (usingAuthentiXStandard) then
Set AuthX = Server.CreateObject("AUTHXOCX.AuthXOCXCtrl.1")
else
Set AuthX = Server.CreateObject("AUTHXISP.AuthXOCXCtrl.1")
protectedDomain = Request.ServerVariables("LOCAL_ADDR")
'protectedDomain = "hostheader.com"
AuthX.SetVirtualDomain protectedDomain, Request.ServerVariables("SCRIPT_NAME")
AuthX.SetVirtualDomainPassword("")
end if
%>
<% currentUser = AuthX.CurrentUserName(Request.ServerVariables("LOCAL_ADDR"), Request.ServerVariables("SCRIPT_NAME"), Request.ServerVariables("HTTP_AUTHORIZATION")) %>
<% If "" = currentUser Then %>
An empty user name, protect this directory with AuthentiX and try again.
<% Else %>
Welcome,
<B>
<%= currentUser %>,
</B>
to AuthentiX OCX!
<% End If %>
Applies To
AuthentiX OCX Component
http://www.flicks.com/authentix/discover/main.htm