Code to Implement Proxy Accounts

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

' 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")

' set the user's userid in the authticket
objAuth.SetAuthTicket strUserID, True, 90

' 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

' create a new guid to allow the authfilter to do lookups in its password cache based on the guid and not the userid in the ticket
Set objGenID =  Server.CreateObject("Commerce.GenID") '$PERF: store one in Application scope in GLOBAL.ASA, Application("MSCSAuthGenID")
strGUID = objGenID.GenGUIDString
 
' set the guid property in the authticket and append it to the querystring as well
objAuth.SetProperty 2, "guid", strGUID ' after setting Ticket
strRetAsp = strRetAsp + "&guid="
strRetAsp = strRetAsp + strGUID

Response.Redirect strRetAsp
end if

See Also

Enabling Proxy Accounts

Copyright © 2005 Microsoft Corporation.
All rights reserved.