This is the VB code I have. It's a page where you can change a user's password. My problem: When I enter 2 different passwords I get redirected by the redirect in the ExistingUser function. I have no idea why.
<%@ Language=VBScript %>
<!-- #include file='../include/variables.asp' -->
<%
Function CheckResult(code)
code = clng(code)
rpn = clng(rpn)
If code = rpn Then
'user successfully modified
Response.Redirect("../mainmenu.asp?lang="&language&"&msg=mod"
ElseIf code = -20210 Then
Response.Redirect("editUser.asp?lang="&language&"&msg=passLenght"
'errormsg = "The password must be atleast six characters."
ElseIf code = -20212 Then
Response.Redirect("editUser.asp?lang="&language&"&msg=passUser"
'errormsg = "The password is invalid. Username and password must not be the same."
ElseIf code = -20213 Then
Response.Redirect("editUser.asp?lang="&language&"&msg=passDiff"
'errormsg = "Could not verify that password differs from username."
ElseIf code = -20214 Then
Response.Redirect("editUser.asp?lang="&language&"&msg=appUser"
'errormsg = "Unable to add application user. Please contact the system administrator."
ElseIf code <> "" Then
Response.Write ("Error# " & code & " has occured.\n Please contact the Administrator."
'error while adding new user
End If
End Function
Function CheckPassword(pwd, pwdConfirm)
If pwd <> pwdConfirm or pwd = "" or pwdConfirm = "" Then
formSubmitted = "no"
errorMsg = "Please re-type your password again."
Else
If ((len(pwd) < 6) or (len(pwdConfirm) < 6)) Then
formSubmitted = "no"
Response.Redirect("editUser.asp?lang="&language&"&msg=passLenght"
Else
formSubmitted = "yes"
End If
End If
End Function
Function ExistingUser(username)
Set oCnn = Server.CreateObject("ADODB.Connection"
Set oCnnString = Server.CreateObject("ABSIntranet.DataAccess"
set rst = Server.CreateObject ("ADODB.Recordset"
sql = "SELECT USER_NAME, ROLE_NAME "&_
"FROM COMMON.APPLICATION_WEBUSER_ROLE "&_
"WHERE USER_NAME = '" & username & "'"&_
"AND PI_ACRO_ID = 115"
oCnn.Open (oCnnString.GetIntraConnectString)
rst.Open sql, oCnn, adOpenDynamic
If rst.BOF or rst.EOF Then
'user not found to edit prefs
Response.Write ("<Script Language=JavaScript>" & chr(13) &_
"alert('User not found!')" & chr(13) &_
"</SCRIPT>" & chr(13))
Response.Redirect ("viewUsers.asp?lang=" & Language)
End If
rst.Close
oCnn.Close
sql = "SELECT * "&_
"FROM COMMON.APPLICATION_USER "&_
"WHERE USER_NAME = '" & username & "'"
oCnn.Open (oCnnString.GetIntraConnectString)
rst.Open sql, oCnn, adOpenDynamic
rpn = trim(rst("RPN"
)
lang = trim(rst("Preferred_Language_Code"
)
oCnn.Close
set oCnn = nothing
set oCnnString = nothing
set rst = nothing
End Function
Const genericUser = "GEN_ABS_SYSTEM"
Dim oCnn, cmd, rst, sql
Dim usr, role, rpn
Dim formAction, formSubmitted, password, passwordConfirm
Response.Buffer = true
usr = ucase(trim(Request.QueryString ("username"
))
lang = trim(Request.Form ("prefLang"
)
password = trim(Request.Form ("password"
)
passwordConfirm = trim(Request.Form ("passwordConfirm"
)
formAction = Request.Form ("formAction"
ExistingUser(usr)
If formAction = "Ok" Then
CheckPassword cstr(password), cstr(passwordConfirm)
If formSubmitted = "yes" Then
role = Request.Form ("accountType"
set oUpdateUser = Server.CreateObject ("ABSIntranet.UserAccess"
Response.Write (CheckResult(oUpdateUser.UpdateUserInfo(usr, password, rpn, lang, Session("UserId"
)))
set oUpdateUser = nothing
Else
Response.Redirect("editUser.asp?lang="&language&"&msg=passLenght"
End If
ElseIf formAction = "submit" Then
If (Session("Group"
= "ABS_PUBLISHER" OR Session("Group"
= "ABS_TRANSLATOR" OR Session("Group"
= "ABS_DATAENTRY"
then
Response.Redirect("/ABSIntranet/mainmenu.asp?lang=" & Language)
Else
Response.Redirect ("/ABSIntranet/UserMgnt/viewUsers.asp?lang=" & Language)
End If
End If
sqlIntra = "SELECT LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'mainmenu.asp' "&_
"AND LABEL_TYPE = 'page_title'"
sqlSub = "SELECT LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'mainmenu.asp' "&_
"AND LABEL_TYPE = 'sub_title'"
sqlSub1 = "SELECT TRANSLATE_NUMBER, LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'editUser.asp'"&_
"AND LABEL_TYPE = 'form_label'"
sqlSub2 = "SELECT TRANSLATE_NUMBER, LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'editUser.asp'"&_
"AND LABEL_TYPE = 'sub_sub_title'"
sqlSub3 = "SELECT TRANSLATE_NUMBER, LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'editUser.asp'"&_
"AND LABEL_TYPE = 'form_item'"
If Request.QueryString ("msg"
= "passLenght" Then
errormsg = "The password must be atleast six characters."
End If
If Request.QueryString ("msg"
= "passUser" Then
errormsg = "The password is invalid. Username and password must not be the same."
End If
If Request.QueryString ("msg"
= "passDiff" Then
errormsg = "Could not verify that password differs from username."
End If
If Request.QueryString ("msg"
= "appUser" Then
errormsg = "Unable to add application user. Please contact the system administrator."
End If
Set oCnn = Server.CreateObject("ADODB.Connection"
Set oCnnString = Server.CreateObject("ABSIntranet.DataAccess"
Set rstIntra = Server.CreateObject("ADODB.Recordset"
oCnn.Open (oCnnString.GetIntraConnectString)
%>
<html>
<head>
<title>ABS Administration</title>
<script language="JavaScript1.2">
function disableButton(){
document.form1.OkButton.disabled = true;
document.form1.CancelButton.disabled = true;
document.form1.formAction.value = "Ok";
document.form1.submit();
}
function disableCancelButton(){
document.form1.OkButton.disabled = true;
document.form1.CancelButton.disabled = true;
document.form1.formAction.value = "submit";
document.form1.submit();
}
</script>
<%
If errorMsg <> "" Then
Response.Write("<Script Language=JavaScript>" & chr(13) & "alert('" & errormsg & "')" & chr(13) & "</SCRIPT>" & chr(13))
errorMsg = ""
End If
%>
<%@ Language=VBScript %>
<!-- #include file='../include/variables.asp' -->
<%
Function CheckResult(code)
code = clng(code)
rpn = clng(rpn)
If code = rpn Then
'user successfully modified
Response.Redirect("../mainmenu.asp?lang="&language&"&msg=mod"
ElseIf code = -20210 Then
Response.Redirect("editUser.asp?lang="&language&"&msg=passLenght"
'errormsg = "The password must be atleast six characters."
ElseIf code = -20212 Then
Response.Redirect("editUser.asp?lang="&language&"&msg=passUser"
'errormsg = "The password is invalid. Username and password must not be the same."
ElseIf code = -20213 Then
Response.Redirect("editUser.asp?lang="&language&"&msg=passDiff"
'errormsg = "Could not verify that password differs from username."
ElseIf code = -20214 Then
Response.Redirect("editUser.asp?lang="&language&"&msg=appUser"
'errormsg = "Unable to add application user. Please contact the system administrator."
ElseIf code <> "" Then
Response.Write ("Error# " & code & " has occured.\n Please contact the Administrator."
'error while adding new user
End If
End Function
Function CheckPassword(pwd, pwdConfirm)
If pwd <> pwdConfirm or pwd = "" or pwdConfirm = "" Then
formSubmitted = "no"
errorMsg = "Please re-type your password again."
Else
If ((len(pwd) < 6) or (len(pwdConfirm) < 6)) Then
formSubmitted = "no"
Response.Redirect("editUser.asp?lang="&language&"&msg=passLenght"
Else
formSubmitted = "yes"
End If
End If
End Function
Function ExistingUser(username)
Set oCnn = Server.CreateObject("ADODB.Connection"
Set oCnnString = Server.CreateObject("ABSIntranet.DataAccess"
set rst = Server.CreateObject ("ADODB.Recordset"
sql = "SELECT USER_NAME, ROLE_NAME "&_
"FROM COMMON.APPLICATION_WEBUSER_ROLE "&_
"WHERE USER_NAME = '" & username & "'"&_
"AND PI_ACRO_ID = 115"
oCnn.Open (oCnnString.GetIntraConnectString)
rst.Open sql, oCnn, adOpenDynamic
If rst.BOF or rst.EOF Then
'user not found to edit prefs
Response.Write ("<Script Language=JavaScript>" & chr(13) &_
"alert('User not found!')" & chr(13) &_
"</SCRIPT>" & chr(13))
Response.Redirect ("viewUsers.asp?lang=" & Language)
End If
rst.Close
oCnn.Close
sql = "SELECT * "&_
"FROM COMMON.APPLICATION_USER "&_
"WHERE USER_NAME = '" & username & "'"
oCnn.Open (oCnnString.GetIntraConnectString)
rst.Open sql, oCnn, adOpenDynamic
rpn = trim(rst("RPN"
lang = trim(rst("Preferred_Language_Code"
oCnn.Close
set oCnn = nothing
set oCnnString = nothing
set rst = nothing
End Function
Const genericUser = "GEN_ABS_SYSTEM"
Dim oCnn, cmd, rst, sql
Dim usr, role, rpn
Dim formAction, formSubmitted, password, passwordConfirm
Response.Buffer = true
usr = ucase(trim(Request.QueryString ("username"
lang = trim(Request.Form ("prefLang"
password = trim(Request.Form ("password"
passwordConfirm = trim(Request.Form ("passwordConfirm"
formAction = Request.Form ("formAction"
ExistingUser(usr)
If formAction = "Ok" Then
CheckPassword cstr(password), cstr(passwordConfirm)
If formSubmitted = "yes" Then
role = Request.Form ("accountType"
set oUpdateUser = Server.CreateObject ("ABSIntranet.UserAccess"
Response.Write (CheckResult(oUpdateUser.UpdateUserInfo(usr, password, rpn, lang, Session("UserId"
set oUpdateUser = nothing
Else
Response.Redirect("editUser.asp?lang="&language&"&msg=passLenght"
End If
ElseIf formAction = "submit" Then
If (Session("Group"
Response.Redirect("/ABSIntranet/mainmenu.asp?lang=" & Language)
Else
Response.Redirect ("/ABSIntranet/UserMgnt/viewUsers.asp?lang=" & Language)
End If
End If
sqlIntra = "SELECT LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'mainmenu.asp' "&_
"AND LABEL_TYPE = 'page_title'"
sqlSub = "SELECT LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'mainmenu.asp' "&_
"AND LABEL_TYPE = 'sub_title'"
sqlSub1 = "SELECT TRANSLATE_NUMBER, LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'editUser.asp'"&_
"AND LABEL_TYPE = 'form_label'"
sqlSub2 = "SELECT TRANSLATE_NUMBER, LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'editUser.asp'"&_
"AND LABEL_TYPE = 'sub_sub_title'"
sqlSub3 = "SELECT TRANSLATE_NUMBER, LABEL_" & Language & "DESC "&_
"FROM ABS.TRANSLATE "&_
"WHERE FILE_NAME = 'editUser.asp'"&_
"AND LABEL_TYPE = 'form_item'"
If Request.QueryString ("msg"
errormsg = "The password must be atleast six characters."
End If
If Request.QueryString ("msg"
errormsg = "The password is invalid. Username and password must not be the same."
End If
If Request.QueryString ("msg"
errormsg = "Could not verify that password differs from username."
End If
If Request.QueryString ("msg"
errormsg = "Unable to add application user. Please contact the system administrator."
End If
Set oCnn = Server.CreateObject("ADODB.Connection"
Set oCnnString = Server.CreateObject("ABSIntranet.DataAccess"
Set rstIntra = Server.CreateObject("ADODB.Recordset"
oCnn.Open (oCnnString.GetIntraConnectString)
%>
<html>
<head>
<title>ABS Administration</title>
<script language="JavaScript1.2">
function disableButton(){
document.form1.OkButton.disabled = true;
document.form1.CancelButton.disabled = true;
document.form1.formAction.value = "Ok";
document.form1.submit();
}
function disableCancelButton(){
document.form1.OkButton.disabled = true;
document.form1.CancelButton.disabled = true;
document.form1.formAction.value = "submit";
document.form1.submit();
}
</script>
<%
If errorMsg <> "" Then
Response.Write("<Script Language=JavaScript>" & chr(13) & "alert('" & errormsg & "')" & chr(13) & "</SCRIPT>" & chr(13))
errorMsg = ""
End If
%>