Login.asp Code for the Retail Solution Site

Following is the code for the Login.asp page for the Retail Solution Site. If you choose to use AuthFilter for the Retail site, you must use this code for your site Login.asp. For more information, see Enabling AuthFilter for the Retail Solution Site.

<!-- #INCLUDE Virtual="retail/include/header.asp" -->
<!-- #INCLUDE Virtual="retail/include/const.asp" -->
<!-- #INCLUDE Virtual=" retail/include/html_lib.asp" -->
<!-- #INCLUDE Virtual="retail/include/form_lib.asp" -->
<!-- #INCLUDE Virtual="retail/include/std_access_lib.asp" -->
<!-- #INCLUDE Virtual="retail/include/std_profile_lib.asp" -->
<!-- #INCLUDE Virtual="retail/include/std_cookie_lib.asp" -->
<!-- #INCLUDE Virtual="retail/include/std_url_lib.asp" -->
<!-- #INCLUDE Virtual="retail/include/std_util_lib.asp" -->
<!-- #INCLUDE Virtual="retail/include/setupenv.asp" -->
<!-- #INCLUDE Virtual="retail/template/no_menu.asp" -->

REM sample file for using with AuthFilter
REM This file handles Login for user


   Sub Main()
   End Sub

   Dim strSelect, strUsername, strPassword, strPWD, retAsp
   dim objAuth
   Dim strAuthErr, strSiteName, sUserID

   set objAuth = Server.CreateObject("Commerce.AuthManager")
   strSiteName = CStr(Application("MSCSCommerceSiteName"))

   'Get the hidden variable to determine if this is the first run of the page
   strSelect = Request.Querystring("realSubmit")

   'If users pressed the submit button
   if strSelect = "fromButton" then
      'authenticate the user
      strUsername = Request.Querystring("txtUsername")
      strPassword = Request.Querystring("txtPassword")

         if (strUsername = "") or (strPassword = "") then
            Response.Redirect "Login.asp"
         end If

         Set mscsUserProfile = GetUserProfileByLoginName(strUsername)
         if (mscsUserProfile is nothing) then
            Response.Redirect "Login.asp"
         end if

         if (mscsUserProfile.Fields("GeneralInfo.user_security_password").Value = strPassword) then
            sUserID = mscsUserProfile.Fields(GetQualifiedName(GENERAL_INFO_GROUP, FIELD_USER_ID)).Value
            ' for Custom/NT Auth
            objAuth.SetAuthTicket sUserID, 1, 90 

            ' Go to the Original requested ASP which is stored in cookie MSCSFirstRequestedURL"
            retAsp = Request.Cookies("MSCSFirstRequestedURL")
            if (retAsp = "" Or IsNUll(retAsp)) then
            retAsp = objAuth.GetURL("default.asp", True, False)
            end if
            Response.Redirect retAsp
            Response.Redirect "Login.asp"
         end if
   End if
  Set objAuth = Nothing
  Set strUserName = “”
  Set strPassword = “”
  Set strPWD = “”

<%Sub PrintLogin() %>
<FORM NAME="frmLogin" ACTION="Login.asp" METHOD="GET">
<H2 ID=L_LoginForm_HTMLText>CS2K-LoginForm</H2><ID Id=L_EnterCredential_ErrorMessage>
To access authenticated content, please enter your UserID & Password</ID>

<H3 ID=L_UserName_HTMLText>Username:<INPUT TYPE="text" NAME="txtUsername" SIZE=32 MAXLENGTH=32><br><ID ID=L_UserPassword_HTMLText>
Password :</ID>
<INPUT TYPE="password" NAME="txtPassword" SIZE=32 MAXLENGTH=32></H3><br>

<INPUT type=HIDDEN name="realSubmit" value="fromButton">
<p align="left">
   <input type="submit" name="action" id=L_Submit_Button value="Submit">
   <input type="reset" name="action" id=L_Reset_Button value="Reset"> 

REM    need to add own registration file under '\AuthFiles\' sub-Dir Or 
Copy ..\Retail\login\newuser.asp to '\AuthFiles\newuser.asp'
REM    in global.asa update: dictPages.NewUser = "AuthFiles/newuser.asp"
<A HRef="newuser.asp" ID=L_RegisterIf_HTMLText>Register if you are a new user 
   (solution sites: need to add own registration file under '\AuthFiles\' sub-Dir Or 
Copy ..\Retail\login\newuser.asp & update NewUser-File in Global.asa)</A>

<%end sub%>

See Also

Enabling AuthFilter for the Retail Solution Site

Copyright © 2005 Microsoft Corporation.
All rights reserved.