%@ Language=VBScript %>
<% Option Explicit %>
<%
'-------------------------------------------------------------------------
' adminpw_prop.asp: Change Administrator Password
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' Date Description
' 25-7-2000 Created date
' 28-2-2001 Modify date
'-------------------------------------------------------------------------
%>
<%
'-------------------------------------------------------------------------
' Global Variables
'-------------------------------------------------------------------------
Dim rc 'framework variables
Dim page 'framework variables
'-------------------------------------------------------------------------
' Form Variables
'-------------------------------------------------------------------------
Dim F_strUserName 'Username for the form
Dim F_strCurrentPassword 'Current Password
Dim F_strNewPassword 'New password
Dim F_strConfirmNewPassword 'Confirm New Password
Dim F_strAdminUserName 'Admin username
'-------------------------------------------------------------------------
'-------------------------------------------------------------------------
' Global Variables
'-------------------------------------------------------------------------
Dim G_strDomainName 'Domain name from system
Dim G_strUserName 'User name from system
Dim G_PwdFlag
Dim G_NameFlag
Dim G_bPwdChangeReq
G_bPwdChangeReq = TRUE
Const CONST_REGKEY ="Name"
Const CONST_HTTPS_OFF="OFF"
' Create a Property Page
rc = SA_CreatePage(L_TASKTITLE_TEXT, "",PT_PROPERTY, page )
'
' Serve the page
rc = SA_ShowPage( page )
'-------------------------------------------------------------------------
'Function: OnInitPage()
'Description: Called to signal first time processing for this page.
' Use this method to do first time initialization tasks
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: None
'-------------------------------------------------------------------------
Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
SA_TraceOut "TEMPLATE_PROPERTY", "OnInitPage"
'Getting values from system
If Request.Form("hdnAdminUserName")="" then
GetDomainandUsername()
End if
If Request.Form("hdnAdminUserName")<>"" then
G_strUserName= Request.Form("hdnAdminUserName")
End if
OnInitPage = TRUE
End Function
'-------------------------------------------------------------------------
'Function: OnServePropertyPage()
'Description: Called when the page needs to be served.Use this
' method to serve content
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: In:G_strUserName,G_strDomainName
'-------------------------------------------------------------------------
Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
'return url modification
SA_TraceOut "TEMPLATE_PROPERTY", "OnServePropertyPage"
If Request.Form("hdnAdminUserName")<>"" then
G_strUserName= Request.Form("hdnAdminUserName")
End if
' Emit Functions required by Web Framework
Call ServeCommonJavaScript()%>
<%CheckForSecureSite()%>
<%=L_USERNAME_TEXT %>
<%=L_CURRENTPASSWORD_TEXT %>
<%=L_NEWPASSWORD_TEXT %>
<%=L_CONFIRMNEWPASSWORD_TEXT %>
<%
OnServePropertyPage = TRUE
End Function
'-------------------------------------------------------------------------
'Function: OnPostBackPage()
'Description: Called to signal that the page has been posted-back.
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: Out:F_strAdminUserName 'admin user name
' Out:F_strCurrentPassword 'Current password
' out:F_strConfirmNewPassword 'Confirm password
'-------------------------------------------------------------------------
Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
Err.Clear
F_strAdminUserName = Request.Form("txtUSERNAME")
F_strCurrentPassword = Request.Form("pwdCURRENTPASSWORD")
F_strNewPassword = Request.Form("pwdNEWPASSWORD")
F_strConfirmNewPassword = Request.Form("pwdCONFIRMNEWPASSWORD")
'Getting values from system
If Request.Form("hdnAdminUserName")="" then
GetDomainandUsername()
End if
If Request.Form("hdnAdminUserName")<>"" then
G_strUserName= Request.Form("hdnAdminUserName")
End if
G_bPwdChangeReq = Request.Form("hdnPwdChanged")
OnPostBackPage = TRUE
End Function
'-------------------------------------------------------------------------
'Function: OnSubmitPage()
'Description: Called when the page has been submitted for processing.
' Use this method to process the submit request.
'Input Variables: PageIn,EventArg
'Output Variables: None
'Returns: True/False
'Global Variables: Out:G_PwdFlag
' Out:F_strAdminUserName 'admin user name
' Out:F_strCurrentPassword 'Current password
' Out:F_strConfirmNewPassword 'Confirm password
' Out:F_strNewPassword
'-------------------------------------------------------------------------
Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
SA_TraceOut "TEMPLATE_PROPERTY", "OnSubmitPage"
Err.Clear
Dim nflag
Const strChange="Change"
F_strAdminUserName = Request.Form("txtUSERNAME")
F_strCurrentPassword = Request.Form("pwdCURRENTPASSWORD")
F_strNewPassword = Request.Form("pwdNEWPASSWORD")
F_strConfirmNewPassword = Request.Form("pwdCONFIRMNEWPASSWORD")
'Getting values from system
GetDomainandUsername()
'Updating the values.
If SetChangepassword()Then
If G_PwdFlag=strChange or G_NameFlag=strChange Then
If G_PwdFlag=strChange and G_NameFlag=strChange Then
nflag=3
Elseif G_PwdFlag=strChange Then
nflag=1
Elseif G_NameFlag=strChange Then
nflag=2
End If
Response.Redirect "adminpw_changeConfirm.asp?flag=" & nflag & _
"&tab1=TabsNetwork" & _
"&tab2=TabsNetworkChangeAdminPW" & _
"&" & SAI_FLD_PAGEKEY & "=" & SAI_GetPageKey()
Else
OnSubmitPage=True
End if
End If
End Function
'-------------------------------------------------------------------------
'Function: OnClosePage()
'Description: Called when the page is about closed.Use this method
' to perform clean-up processing
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: None
'-------------------------------------------------------------------------
Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
SA_TraceOut "TEMPLATE_PROPERTY", "OnClosePage"
OnClosePage = TRUE
End Function
'-------------------------------------------------------------------------
'Function: GetDomainandUsername
'Description: Serves in Getting the data from Client
'Input Variables: None
'Output Variables: None
'Returns: None
'Global Variables: Out:G_strDomainName 'Domain Name
' Out:G_strUserName 'Username
' Out:F_strUserName 'Getting Username from server
' In :L_UNABLETOCREATELOCALIZATIONOBJECT_ERRORMESSAGE
'
' Unable to get remoteuser using servervariables, calls Sa_SetErrMsg with the error string
' L_UNABLETOCREATELOCALIZATIONOBJECT_ERRORMESSAGE and never returns.
'---------------------------------------------------------------------------------------------------------------------------------------------------
Function GetDomainandUsername
on error resume next
Err.Clear
Dim strTemp
F_strUserName = Request.ServerVariables("REMOTE_USER")
If Err.Number <> 0 Then
Sa_SetErrMsg L_UNABLETOCREATELOCALIZATIONOBJECT_ERRORMESSAGE
SA_TraceOut "ADMINPW_PROP", L_UNABLETOCREATELOCALIZATIONOBJECT & "("& Hex(Err.number ) & ")"
GetDomainandUsername = FALSE
Exit Function
End if
If InStr(F_strUserName, "\") Then
strTemp = Split(F_strUserName,"\")
G_strDomainName = strTemp(0)
G_strUserName = strTemp(1)
Else
G_strDomainName = GetComputerName
G_strUserName = F_strUserName
End If
GetDomainandUsername=True
End Function
'-------------------------------------------------------------------------
'Function name: SetChangepassword
'Description: Changes the administrator password
'Input Variables: None
'Output Variables: None
'Returns: None
'Global Variables:
' In:G_strDomainName 'ADSI Domain name
' In:G_strUserName 'ADSI User name
' In:L_ADSI_ERRORMESSAGE 'ADSI Error Message
' In:L_PASSWORDCOMPLEXITY_ERRORMESSAGE
' 'Complexity Error Message
' In:L_OLDPASSWORDNOTMATCH_ERRORMESSAGE
' 'Old Password not match Error
'
' If ADSI Error, calls Sa_SetErrMsg with the error string
' L_ADSI_ERRORMESSAGE and never returns.
' If Password Complexity error, calls Sa_SetErrMsg with the error string
' L_PASSWORDCOMPLEXITY_ERRORMESSAGE and never returns.
' If old password not match, calls Sa_SetErrMsg with the error string
' L_OLDPASSWORDNOTMATCH_ERRORMESSAGE and never returns.
'--------------------------------------------------------------------------
Function SetChangepassword()
on error resume next
Err.Clear
Dim objUser ' for user object
Dim strADSIPath ' for adsi path
Dim objComputer ' for computer object
Dim objUser1 ' for user object
Dim objRegistry
Dim retVal
Const strChange="Change"
Set objComputer = GetObject("WinNT://" & GetComputerName())
Set objUser1 = objComputer.GetObject("User",G_strUserName)
strADSIPath = "WinNT://" & G_strDomainName & "/" & G_strUserName & ",user"
Set objUser = GetObject(strADSIPath)
'ADSI Error Message
If Err.Number <> 0 Then
Sa_SetErrMsg L_ADSI_ERRORMESSAGE
SA_TraceOut "ADMINPW_PROP", L_ADSI_ERRORMESSAGE & "("& Hex(Err.number ) & ")"
SetChangepassword= FALSE
Exit Function
End if
if G_bPwdChangeReq then
objUser.ChangePassword F_strCurrentPassword, F_strNewPassword
'Method calling to change the Password
If F_strCurrentPassword <> F_strNewPassword then
G_PwdFlag = strChange
End if
'Password Complexity Error Message
If Err.Number = -2147022651 Then
Sa_SetErrMsg L_PASSWORDCOMPLEXITY_ERRORMESSAGE
SA_TraceOut "ADMINPW_PROP", L_PASSWORDCOMPLEXITY_ERRORMESSAGE & "("& Hex(Err.number ) & ")"
SetChangepassword= FALSE
Exit Function
End if
'Old Password Not Match Error Message
If Err.Number= -2147024810 Then
Sa_SetErrMsg L_OLDPASSWORDNOTMATCH_ERRORMESSAGE
SA_TraceOut "ADMINPW_PROP", L_OLDPASSWORDNOTMATCH_ERRORMESSAGE & "("& Hex(Err.number ) & ")"
SetChangepassword= FALSE
Exit Function
End if
'If it fails for other reasons, the error message
If Err.Number<> 0 Then
Sa_SetErrMsg L_PASSWORDCOULDNOTCHANGE_ERRORMESSAGE
SA_TraceOut "ADMINPW_PROP", L_PASSWORDCOULDNOTCHANGE_ERRORMESSAGE & "("& Hex(Err.number ) & ")"
SetChangepassword= FALSE
Exit Function
End if
End if
If Ucase(F_strAdminUserName) <> Ucase(G_strUserName) Then
objComputer.MoveHere objUser1.AdsPath,F_strAdminUserName
G_NameFlag=strChange
If Err.number = -2147022672 then
Sa_SetErrMsg L_THEACCOUNTALREADYEXISTS__ERRORMESSAGE
SetChangepassword= FALSE
Exit Function
End if
End if
Set objComputer =Nothing
Set objUser1=Nothing
Set objUser=Nothing
Set objRegistry =Nothing
SetChangepassword= TRUE
End Function
'-------------------------------------------------------------------------
'Function: ServeCommonJavaScript
'Description: Serves in initialiging the values,setting the form
' data and validating the form values
'Input Variables: None
'Output Variables: None
'Returns: None
'Global Variables: L_(*)
'-------------------------------------------------------------------------
Function ServeCommonJavaScript()
%>
<%
End Function
%>