Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interesting problem - long

Status
Not open for further replies.

FranckM

Programmer
May 8, 2002
76
CA
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(&quot;../mainmenu.asp?lang=&quot;&language&&quot;&msg=mod&quot;)
ElseIf code = -20210 Then
Response.Redirect(&quot;editUser.asp?lang=&quot;&language&&quot;&msg=passLenght&quot;)
'errormsg = &quot;The password must be atleast six characters.&quot;
ElseIf code = -20212 Then
Response.Redirect(&quot;editUser.asp?lang=&quot;&language&&quot;&msg=passUser&quot;)
'errormsg = &quot;The password is invalid. Username and password must not be the same.&quot;
ElseIf code = -20213 Then
Response.Redirect(&quot;editUser.asp?lang=&quot;&language&&quot;&msg=passDiff&quot;)
'errormsg = &quot;Could not verify that password differs from username.&quot;
ElseIf code = -20214 Then
Response.Redirect(&quot;editUser.asp?lang=&quot;&language&&quot;&msg=appUser&quot;)
'errormsg = &quot;Unable to add application user. Please contact the system administrator.&quot;
ElseIf code <> &quot;&quot; Then
Response.Write (&quot;Error# &quot; & code & &quot; has occured.\n Please contact the Administrator.&quot;)
'error while adding new user
End If
End Function

Function CheckPassword(pwd, pwdConfirm)
If pwd <> pwdConfirm or pwd = &quot;&quot; or pwdConfirm = &quot;&quot; Then
formSubmitted = &quot;no&quot;
errorMsg = &quot;Please re-type your password again.&quot;
Else
If ((len(pwd) < 6) or (len(pwdConfirm) < 6)) Then
formSubmitted = &quot;no&quot;
Response.Redirect(&quot;editUser.asp?lang=&quot;&language&&quot;&msg=passLenght&quot;)
Else
formSubmitted = &quot;yes&quot;
End If
End If
End Function

Function ExistingUser(username)
Set oCnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set oCnnString = Server.CreateObject(&quot;ABSIntranet.DataAccess&quot;)
set rst = Server.CreateObject (&quot;ADODB.Recordset&quot;)

sql = &quot;SELECT USER_NAME, ROLE_NAME &quot;&_
&quot;FROM COMMON.APPLICATION_WEBUSER_ROLE &quot;&_
&quot;WHERE USER_NAME = '&quot; & username & &quot;'&quot;&_
&quot;AND PI_ACRO_ID = 115&quot;

oCnn.Open (oCnnString.GetIntraConnectString)
rst.Open sql, oCnn, adOpenDynamic

If rst.BOF or rst.EOF Then
'user not found to edit prefs
Response.Write (&quot;<Script Language=JavaScript>&quot; & chr(13) &_
&quot;alert('User not found!')&quot; & chr(13) &_
&quot;</SCRIPT>&quot; & chr(13))
Response.Redirect (&quot;viewUsers.asp?lang=&quot; & Language)
End If

rst.Close
oCnn.Close

sql = &quot;SELECT * &quot;&_
&quot;FROM COMMON.APPLICATION_USER &quot;&_
&quot;WHERE USER_NAME = '&quot; & username & &quot;'&quot;

oCnn.Open (oCnnString.GetIntraConnectString)
rst.Open sql, oCnn, adOpenDynamic
rpn = trim(rst(&quot;RPN&quot;))
lang = trim(rst(&quot;Preferred_Language_Code&quot;))

oCnn.Close
set oCnn = nothing
set oCnnString = nothing
set rst = nothing
End Function

Const genericUser = &quot;GEN_ABS_SYSTEM&quot;

Dim oCnn, cmd, rst, sql
Dim usr, role, rpn
Dim formAction, formSubmitted, password, passwordConfirm

Response.Buffer = true

usr = ucase(trim(Request.QueryString (&quot;username&quot;)))
lang = trim(Request.Form (&quot;prefLang&quot;))
password = trim(Request.Form (&quot;password&quot;))
passwordConfirm = trim(Request.Form (&quot;passwordConfirm&quot;))
formAction = Request.Form (&quot;formAction&quot;)

ExistingUser(usr)

If formAction = &quot;Ok&quot; Then

CheckPassword cstr(password), cstr(passwordConfirm)

If formSubmitted = &quot;yes&quot; Then
role = Request.Form (&quot;accountType&quot;)

set oUpdateUser = Server.CreateObject (&quot;ABSIntranet.UserAccess&quot;)
Response.Write (CheckResult(oUpdateUser.UpdateUserInfo(usr, password, rpn, lang, Session(&quot;UserId&quot;))))
set oUpdateUser = nothing
Else
Response.Redirect(&quot;editUser.asp?lang=&quot;&language&&quot;&msg=passLenght&quot;)
End If
ElseIf formAction = &quot;submit&quot; Then
If (Session(&quot;Group&quot;) = &quot;ABS_PUBLISHER&quot; OR Session(&quot;Group&quot;) = &quot;ABS_TRANSLATOR&quot; OR Session(&quot;Group&quot;) = &quot;ABS_DATAENTRY&quot;) then
Response.Redirect(&quot;/ABSIntranet/mainmenu.asp?lang=&quot; & Language)
Else
Response.Redirect (&quot;/ABSIntranet/UserMgnt/viewUsers.asp?lang=&quot; & Language)
End If
End If

sqlIntra = &quot;SELECT LABEL_&quot; & Language & &quot;DESC &quot;&_
&quot;FROM ABS.TRANSLATE &quot;&_
&quot;WHERE FILE_NAME = 'mainmenu.asp' &quot;&_
&quot;AND LABEL_TYPE = 'page_title'&quot;

sqlSub = &quot;SELECT LABEL_&quot; & Language & &quot;DESC &quot;&_
&quot;FROM ABS.TRANSLATE &quot;&_
&quot;WHERE FILE_NAME = 'mainmenu.asp' &quot;&_
&quot;AND LABEL_TYPE = 'sub_title'&quot;

sqlSub1 = &quot;SELECT TRANSLATE_NUMBER, LABEL_&quot; & Language & &quot;DESC &quot;&_
&quot;FROM ABS.TRANSLATE &quot;&_
&quot;WHERE FILE_NAME = 'editUser.asp'&quot;&_
&quot;AND LABEL_TYPE = 'form_label'&quot;

sqlSub2 = &quot;SELECT TRANSLATE_NUMBER, LABEL_&quot; & Language & &quot;DESC &quot;&_
&quot;FROM ABS.TRANSLATE &quot;&_
&quot;WHERE FILE_NAME = 'editUser.asp'&quot;&_
&quot;AND LABEL_TYPE = 'sub_sub_title'&quot;

sqlSub3 = &quot;SELECT TRANSLATE_NUMBER, LABEL_&quot; & Language & &quot;DESC &quot;&_
&quot;FROM ABS.TRANSLATE &quot;&_
&quot;WHERE FILE_NAME = 'editUser.asp'&quot;&_
&quot;AND LABEL_TYPE = 'form_item'&quot;

If Request.QueryString (&quot;msg&quot;) = &quot;passLenght&quot; Then
errormsg = &quot;The password must be atleast six characters.&quot;
End If
If Request.QueryString (&quot;msg&quot;) = &quot;passUser&quot; Then
errormsg = &quot;The password is invalid. Username and password must not be the same.&quot;
End If
If Request.QueryString (&quot;msg&quot;) = &quot;passDiff&quot; Then
errormsg = &quot;Could not verify that password differs from username.&quot;
End If
If Request.QueryString (&quot;msg&quot;) = &quot;appUser&quot; Then
errormsg = &quot;Unable to add application user. Please contact the system administrator.&quot;
End If

Set oCnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set oCnnString = Server.CreateObject(&quot;ABSIntranet.DataAccess&quot;)
Set rstIntra = Server.CreateObject(&quot;ADODB.Recordset&quot;)

oCnn.Open (oCnnString.GetIntraConnectString)
%>
<html>
<head>

<title>ABS Administration</title>

<script language=&quot;JavaScript1.2&quot;>

function disableButton(){
document.form1.OkButton.disabled = true;
document.form1.CancelButton.disabled = true;
document.form1.formAction.value = &quot;Ok&quot;;
document.form1.submit();
}

function disableCancelButton(){
document.form1.OkButton.disabled = true;
document.form1.CancelButton.disabled = true;
document.form1.formAction.value = &quot;submit&quot;;
document.form1.submit();
}
</script>
<%
If errorMsg <> &quot;&quot; Then
Response.Write(&quot;<Script Language=JavaScript>&quot; & chr(13) & &quot;alert('&quot; & errormsg & &quot;')&quot; & chr(13) & &quot;</SCRIPT>&quot; & chr(13))
errorMsg = &quot;&quot;
End If
%>
 
If rst.BOF or rst.EOF then
...

I assume that this is where your redirect occurs. If you just opened the recordset, you will be at BOF, so the redirect will execute. Don't you just want to check for no record (EOF)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top