ODBCRemoveUserFromCache
The ODBCRemoveUserFromCache method
removes a user from the 10 minute ODBC username cache.
Use this function if you change the users password in your ODBC database, as in the example below,
and the change will be updated immediately. This function does not remove the username and password
from the browser's cache. See the
FAQ item on this.
Note, with IIS5 and above, the function will only work if
the Application Protection is set to
"Low (IIS Process)" in the
MMC/IIS - Properties - Home Directory for the current directory.
This is because the function needs to be called in the same process
in which the AuthentiX ISAPI filter is running - the IIS main process.
Syntax
ODBCRemoveUserFromCache(userName)
Parameters
-
userName
-
The username to remove from the cache.
Return Values
Returns 0.
Example
The following example changes a password in an ODBC database,
and removes the user from the AuthentiX cache.
<%
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
%>
<%
<%@ LANGUAGE="VBSCRIPT"%>
<%
'Validate password change information
if IsEmpty(Request.Form("PASSWORD_TX_OLD")) then
response.redirect "password.asp?MSG=INCOMPLETE"
end if
if IsEmpty(Request.Form("PASSWORD_TX")) then
response.redirect "password.asp?MSG=INCOMPLETE"
end if
if IsEmpty(Request.Form("PASSWORD_TX_CONFIRM")) then
response.redirect "password.asp?MSG=INCOMPLETE"
end if
'Get current username from Authentix, then database
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"))
Set Connection1 = Server.CreateObject("ADODB.Connection")
Connection1.Open "CWUSERS"
SQLQueryString = "SELECT * from users where "
SQLQueryString = SQLQueryString & "USERNAME_TX = '" & Trim(currentUser) & "' "
Set RSGetUser = Server.CreateObject("ADODB.RecordSet")
RSGetUser.open SQLQueryString, Connection1, 3
'Compare form input with passwords from DB
if Trim(Request.Form("PASSWORD_TX_OLD")) <>
Trim(RSGetUser("PASSWORD_TX")) then
response.redirect "password.asp?MSG=WRONGPASSWORD"
else
if Trim(Request.Form("PASSWORD_TX")) <>
Trim(Request.Form("PASSWORD_TX_CONFIRM")) then
response.redirect "password.asp?MSG=WRONGPASSWORDCONFIRM"
else
if Len(Trim(Request.Form("PASSWORD_TX"))) < 6 then
response.redirect "password.asp?MSG=PASSWORDTOOSHORT"
else
'update DB with new password
SQL2 = "UPDATE users "
SQL2 = SQL2 & "SET PASSWORD_TX = '" & Trim(Request.Form("PASSWORD_TX"))
& "' "
SQL2 = SQL2 & "WHERE USER_ID = " & RSGetUser("USER_ID") & " "
Set RSChangePassword = Connection1.Execute(SQL2)
'Clear this username from the Authentix ODBC cache
AuthX.ODBCRemoveUserFromCache(Trim(currentUser))
'redirect back to password change form
response.redirect "password.asp?MSG=CHANGED"
end if
end if
end if
%>
Applies To
AuthentiX OCX Component
http://www.flicks.com/authentix/discover/main.htm