Sub Initialize
        Dim session As New NotesSession
        Dim ThisDB As NotesDatabase, DirectoryDB As NotesDatabase
        Dim UserView As NotesView
        Dim ThisDoc As NotesDocument, UserDoc As NotesDocument

        Dim UserName As NotesName

        Dim Adminp As NotesAdministrationProcess


        Dim sUserName As String

        sUserName = session.EffectiveUserName
        Set UserName = New NotesName(sUserName)

        Set ThisDB = session.CurrentDatabase
        Set ThisDoc = session.DocumentContext
        Set DirectoryDB = New NotesDatabase("", "names.nsf")

        Set Adminp = session.CreateAdministrationProcess(ThisDB.Server)

        If DirectoryDB.IsOpen Then

                Set UserView = DirectoryDB.GetView("($Users)") 
                If Not UserView Is Nothing Then

                        Set UserDoc = UserView.GetDocumentByKey(sUserName, True)
                        If Not UserDoc Is Nothing Then
                                If session.VerifyPassword(ThisDoc.Password(0), UserDoc.HTTPPassword(0)) Then
                                        'Correct old password entered<br />"
                                        'Check new passwords match
                                        If ThisDoc.PasswordNew(0) <> ThisDoc.PasswordConfirm(0) Then
                                                Print "location:/"+ThisDB.FilePath+"/pwChange?openform&reasonType=5"
                                        Else
                                                'Check format of password
                                                If Len(ThisDoc.PasswordNew(0)) < 6 Then
                                                        Print "New password not long enough"
                                                Else
                                                        'Check rules = alphanumeric
                                                        If ThisDoc.PasswordNew(0) Like "*[A-z]*" And ThisDoc.PasswordNew(0) Like "*#*" Then

                                                                'Everything is ok. Changing password now..
                                                                Call Adminp.ChangeHTTPPassword( UserName.Canonical , ThisDoc.Password(0) , ThisDoc.PasswordNew(0) )
                                                                Print "location:/"+ThisDB.FilePath+"/pwChanged?openform"

                                                        Else 

                                                                'Print "Wrong format. Must contain both letters <b>and</b> numbers, with no spaces!"
                                                                Print "location:/"+ThisDB.FilePath+"/pwChange?openform&reasonType=15"

                                                        End If
                                                End If
                                        End If
                                Else
                                        Print "Wrong password entered"
                                End If
                        Else
                                Print "Can't open user document"
                        End If
                Else
                        Print "Can't open nab view"
                End If
        Else
                Print "Can't open nab"
        End If
End Sub