Code to Implement Proxy Accounts in a Web Farm Scenario

The following example code is a snippet of the Login.asp file, which has been customized to support the use of proxy accounts in a Web farm scenario.

' if the user has a valid authticket but was redirected here, it must mean that the request was bounced to a new server on the farm
' and the authfilter on this server does not have the credentials in its cache
if (objAuth.IsAuthenticated()) then
' retrieve the userid from the authticket
strUserID = objAuth.GetUserID(1)

' retrieve the profile for the user
Set objMSCSProfileService = Application("MSCSProfileService")
Set objMSCSProfileObj = objMSCSProfileService.GetProfile(strUserID, "UserObject")' GetUserProfileByLoginName(strUsername)
if (objMSCSProfileObj is nothing) then
' clear the authticket before redirecting back to login page because the profile for the user does
' not exist and will treat this as a new login request
objAuth.SetAuthTicket "", true, 90
Response.Redirect "Login.asp"
end if

' these are the new properties that were created to extend the user profile to contain the proxyuser and proxypassword values
proxyUser = objMSCSProfileObj.Fields.Item("GeneralInfo").Value.Item("proxy_user") 
proxyPassword = objMSCSProfileObj.Fields.Item("GeneralInfo").Value.Item("proxy_password")

' appened the proxyuser and proxypassword the querystring to allow the authfilter to use these credentials
strRetAsp = Request.Cookies("MSCSFirstRequestedURL")
strRetAsp = strRetAsp + "&proxyuser="
strRetAsp = strRetAsp + proxyUser
strRetAsp = strRetAsp + "&proxypwd="
strRetAsp = strRetAsp + proxyPassword

' retrieve the guid that is already in the authticket
strGUID = objAuth.GetProperty 1, "guid"
if len(strGUID) = 0 then
' if there isn't one, then create a new one
Set objGenID =  Server.CreateObject("Commerce.GenID")
strGUID = objGenID.GenGUIDString
objAuth.SetProperty 2, "guid", strGUID ' after setting Ticket
end if

' append the guid to the querystring as
strRetAsp = strRetAsp + "&guid="
strRetAsp = strRetAsp + strGUID

' redirect to the originally requested url
Response.Redirect strRetAsp
end if

See Also

Enabling Proxy Accounts

Using Proxy Accounts in a Web Farm

Copyright © 2005 Microsoft Corporation.
All rights reserved.