HTTP Password Setting via Notes and the Web Using @Functions, Script and JavaScript

All the code in one place to allow users to set or change their HTTP password via Notes.

Finally, all the code in one place to allow users to set or change their HTTP password via Notes or the Web using

@Commands, Script and JavaScript!

Brief description:
Notes form:
Button to prompt users for password(s) which uses @commands to mask entered values. Script Agent to set HTTP value in NAB.

Web Form:
Forced authentication using ?OpenForm&Login
JavaScript for input validation WebQuerySave Script Agent to set HTTP values in NAB. Computed fields for Language preferences using cookie and @DBlookups.

Quick review of requirements:
Bilingual (French and English)
Secure (enforce Notes Logoff and authentication in Notes and Web)
Initial Setup of password through Notes.
Masked password entry in Notes.
Forced password length.
Re-entered password for verification.

Notes form
A button is sent to users with the following code which composes another form with some verbiage, a button, and two fields.

Button Code
@PostedCommand([ToolsUserLogoff]);
@Command( [ToolsRunMacro] ; "(Password)" )

Fields
First_Password
Second_Password

Agents
Password Agent:
tmp := @Prompt([PASSWORD]; "HTTP Password Setup";"Enter Your Password:
(Passwords are case sensitive) The minimum number of characters required is 8.";"";"";"");
tmp2 := @Prompt([PASSWORD];"HTTP Password Setup" ;"Enter your Password again for verification: " ;"";"";"");
FIELD First_Password := tmp;
FIELD Second_Password := tmp2;
@PostedCommand([FileSave]);
@PostedCommand([FileSave]);
@Command([ToolsRunMacro];"(SETPassword)")

SETPassword (Manually from Agent list, Selected Documents)
Sub Initialize
Dim ws As New notesuiworkspace
Dim psswrd As String
Dim psswrd1 As String
Dim session As New NotesSession
Dim db1 As notesdatabase
Dim db2 As notesdatabase
Dim view As NotesView
Dim doc As notesdocument
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Set db1 = session.CurrentDatabase

psswrd = uidoc.FieldGetText( "First_Password" )
If Len(psswrd) < 8 Then
Msgbox("Your Password must be at least 8 characters long. Please try again.")
Exit Sub
End If

psswrd1 = uidoc.FieldGetText("Second_Password")
If psswrd <> psswrd1 Then
Msgbox("Password Mismatch. Passwords are case sensitive.")
Exit Sub
Else
Set db2 = New notesdatabase("SERVER", "names.nsf")
Set view = db2.getview("($VIMPeople)")
Set doc = view.getdocumentbykey(session.commonusername)

doc.HTTPPassword = psswrd
Call doc.computewithform(True,False)
Call doc.save(True,False)
Msgbox("Your Password has been updated.")
Call uidoc.FieldClear( "First_Password" )
Call uidoc.FieldClear( "Second_Password" )
Call uidoc.Save
Call uidoc.Close
End If

End Sub

Web Form
Force authentication on form using OpenForm&Login. UserId is pre-filled based on login uthentication.

JavaScript
<script language = javascript>

function mySubmit() {
f = document.forms[0];
var temp = new String(f.elements["New_Password"].value);
//Ensure that all fields are filled in, switch focus to offending field
if (f.elements["New_Password"].value == "") {
alert ("[ComputedNotesField]");
f.elements["New_Password"].focus();
}
else if (f.elements["New_Password2"].value == "" ) {
alert ("[ComputedNotesField]");
f.elements["New_Password2"].focus();

}
else if (f.elements["New_Password"].value != f.elements["New_Password2"].value
) {
alert ("[ComputedNotesField]");
f.elements["New_Password2"].focus();
}
else if (temp.length < 8 ) {
alert ("[ComputedNotesField]");
f.elements["New_Password"].focus();
}
else {
//all mandatory fields are completed so submit form, call agent specified in
WebQuerySave
alert ("" );
f.submit();
}

}//my submit

*LT;/script>

<center><Font size=4>
<!---->

<input type=button value="" onClick = 'mySubmit()'> </Font></center>

Notes form
A button is sent to users with the following code which composes another form with some verbiage, a button, and two fields.

Button Code
@PostedCommand([ToolsUserLogoff]);
@Command( [ToolsRunMacro] ; "(Password)" )

Fields
First_Password
Second_Password

Agents
Password Agent:
tmp := @Prompt([PASSWORD]; "HTTP Password Setup";"Enter Your Password:
(Passwords are case sensitive) The minimum number of characters required is 8.";"";"";"");
tmp2 := @Prompt([PASSWORD];"HTTP Password Setup" ;"Enter your Password again for verification: " ;"";"";"");
FIELD First_Password := tmp;
FIELD Second_Password := tmp2;
@PostedCommand([FileSave]);
@PostedCommand([FileSave]);
@Command([ToolsRunMacro];"(SETPassword)")

SETPassword (Manually from Agent list, Selected Documents)
Sub Initialize
Dim ws As New notesuiworkspace
Dim psswrd As String
Dim psswrd1 As String
Dim session As New NotesSession
Dim db1 As notesdatabase
Dim db2 As notesdatabase
Dim view As NotesView
Dim doc As notesdocument
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Set db1 = session.CurrentDatabase

psswrd = uidoc.FieldGetText( "First_Password" )
If Len(psswrd) < 8 Then
Msgbox("Your Password must be at least 8 characters long. Please try again." )
Exit Sub
End If

psswrd1 = uidoc.FieldGetText("Second_Password")
If psswrd <> psswrd1 Then
Msgbox("Password Mismatch. Passwords are case sensitive.")
Exit Sub
Else
Set db2 = New notesdatabase("SERVER", "names.nsf")
Set view = db2.getview("($VIMPeople)")
Set doc = iew.getdocumentbykey(session.commonusername)

doc.HTTPPassword = psswrd
Call doc.computewithform(True,False)
Call doc.save(True,False)
Msgbox("Your Password has been updated.")
Call uidoc.FieldClear( "First_Password" )
Call uidoc.FieldClear( "Second_Password" )
Call uidoc.Save
Call uidoc.Close
End If

End Sub


Web Form
Force authentication on form using ?OpenForm&Login. UserId is pre-filled based on login authentication.

JavaScript
<script language = javascript>

function mySubmit() {
f = document.forms[0];
var temp = new String(f.elements["New_Password"].value);
//Ensure that all fields are filled in, switch focus to offending field if (f.elements["New_Password"].value == "") {
alert ("[ComputedNotesField]");
f.elements["New_Password"].focus();
}
else if (f.elements["New_Password2"].value == "" ) {
alert ("[ComputedNotesField]");
f.elements["New_Password2"].focus();
}
else if (f.elements["New_Password"].value != f.elements["New_Password2"].value
{
alert ("[ComputedNotesField]");
f.elements["New_Password2"].focus();
}
else if (temp.length < 8 ) {
alert ("[ComputedNotesField]");
f.elements["New_Password"].focus();
}
else {
//all mandatory fields are completed so submit form, call agent specified in WebQuerySave
alert ("[ComputedNotesField]" );
f.submit();
}

}//my submit

</script>

<center><Font size=4>
<!---->
<input type=button value="" onClick = 'mySubmit()'>
</Font></center>
<input type=button value="" onClick = 'mySubmit()'>
</Font></center>

WebQuerySave Agent (Mannual, Run Once)

Sub Initialize
Dim s As New NotesSession
Dim doc As NotesDocument

Dim Db As New NotesDatabase("","")
Dim view As notesview
Dim persondoc As notesdocument
Dim v As Variant
Dim w As Variant

' Check if person is in the NAB

On Error Goto Errhandle

Set doc = s.DocumentContext

Call db.Open("", "names.nsf")

Set view = db.getview("($VIMPeople)")

Set persondoc = view.getdocumentbykey(doc.User_ID(0))

w= Evaluate("@Password(New_Password)", doc)
Call persondoc.ReplaceItemValue("HTTPPassword", w)
Call persondoc.computewithform(True, False)
Call persondoc.save(True,False)

Print doc.path(0)
Exit Sub

Errhandle:
messageText$ = "Error" & Str(Err) & ": " & Error$

PopUpMessage$ = |<SCRIPT language="JavaScript">| & | alert("| & messageText$ &|"); | & | location.href="./" | & |</SCRIPT>| Print PopUpMessage$ ' send this to the user
Exit Sub

End Sub

Computed Notes Fields for JavaScript Alert
Lookups are done based on language values set in Cookie.
FIELD Column := Column; @DbLookup("":"No Cache"; "": "LookupDB.nsf";"Password Messages";"UserId"; Column)

N.B. Column is a field on the Web Form that looks at the language values in the Users cookie.

function mySubmit() {
f = document.forms[0];
var temp = new String(f.elements["New_Password"].value);
//Ensure that all fields are filled in, switch focus to offending field
if (f.elements["New_Password"].value == "") {
alert ("");
f.elements["New_Password"].focus();
}
else if (f.elements["New_Password2"].value == "" ) {
alert ("");
f.elements["New_Password2"].focus();
}
else if (f.elements["New_Password"].value != f.elements
["New_Password2"].value ) {
alert ("");
f.elements["New_Password2"].focus();
}
else if (temp.length < 8 ) {
alert ("");
f.elements["New_Password"].focus();
}
else {
//all mandatory fields are completed so submit form, call agent specified in WebQuerySave
alert ("" );
f.submit();
}

}//my submit

</script>

<center><Font size=4>
<!---->
<input type=button value="" onClick = 'mySubmit()'>
</Font></center>

This was first published in November 2000

Dig deeper on Domino Resources - Part 6

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close