Forgot internet password?

Here is a little background…I am trying to build a ‘Forgot Password’ link on our home page. How I envision it working is a two step process. (First step) A person will fill in a form containing: first initial

	last name 

	last 4 of the ssn

	answers to 3 challenge questions

Then when the user forgets their password, they will click on a link on our login page (2nd step) This link will bring them to a page asking for their first initial, last name and last 4 of the social. Then they hit a refresh button, there is a lookup that happens and if the lookup is successful, (containing the user name and answers they provided in the first step) a second set of fields shows up (the previous challenge questions) After they answer the questions, a set of change password fields come up. I have populated the username with the username from the database but they still haven’t authenticated with our server. Then they are supposed to enter the new password and confirm and then submit.

Here is my question: The submit runs but returns “Your name could not be located in the address book”. Below is the webquerysave agent that actually changes the http password. ( I downloaded the password change db from the sandbox…)

Dim session As Notessession

Dim curdoc As NotesDocument

Dim dbNames As NotesDatabase

Dim viewNames As NotesView

Dim docNames As NotesDocument

Dim newPassword As String

Dim encodedNewPassword As String

Dim passwordInAddressBook As String

Dim temp As Variant

Sub Initialize

Set session = New Notessession

' Gets the current document

Set curdoc = session.DocumentContext

' Gets the primary address book

Set dbNames = session.GetDatabase("","names.nsf")

' Gets the hidden view of person documents

Set viewNames = dbNames.GetView("($VIMPeople)")

' Gets the person document for the user

Set docNames = viewNames.GetDocumentByKey(curdoc.GetItemValue("UserName")(0), True)



' Give error if user is not located in address book

' This can happen if user has not logged in the server or if username is in some secondary address book

If docNames Is Nothing Then

	Print "[/" & curdoc.GetItemValue("DbPath")(0) & "/message?OpenForm&1]"

	Exit Sub		

End If



' Gets the new password entered by user

newPassword = curdoc.GetItemValue("NewPassword")(0)

' Gets the encoded password stored in user's person document

passwordInAddressBook = docNames.HTTPPassword(0)



' Gets the encoded form of the new password

temp = Evaluate({@Password(NewPassword)}, curdoc)

encodedNewPassword = temp(0)



' Updates the person document

docNames.HTTPPassword = encodedNewPassword

Call docNames.Save(True, False)



Print "[/" & curdoc.GetItemValue("DbPath")(0) & "/message?OpenForm&3]"



' End

End Sub

Subject: Forgot internet password?

dont know if this is the problem but there is a bug in your code:

Set docNames = viewNames.GetDocumentByKey(curdoc.GetItemValue(“UserName”)(0), True)

should be:

Set docNames = viewNames.GetDocumentByKey(curdoc.UserName(0), True)

Subject: RE: Forgot internet password?

Huh? GetItemValue is the correct syntax. Using the fieldname alone is “extended class syntax”, and it’s just a shortcut available to LotusScript only. (In COM, you need to use GetItemValue.)

Subject: RE: Forgot internet password?

Didn’t realise this was COM. I only ever use field name short-cut in my LS.

If it is COM I suppose this code wont work in his script then:

passwordInAddressBook = docNames.HTTPPassword(0)

Subject: RE: Forgot internet password?

It’s not COM (or at least there was no mention of it being COM). It’s just that the “.fieldname” thing IS just a shortcut, and the method syntax is the “more correct” version. And it makes it easier to copy-and-paste code between, say, Visual Sudio or the VBA macro editor and Designer, and I’m just lazy enough at heart to take full advantage of that.

Subject: RE: Forgot internet password?

Ah i see yeh, I could see how it would be good in that sense, lucky for me I don’t work in the MS world too much these days! :slight_smile:

Subject: Forgot internet password?

Try Dim personName As String personName=Session.CreateName(curdoc.GetItemValue(“UserName”)(0)).Canonical

Set viewNames=dbNames.GetView(“($Users)”)

Set docNames=viewNames.GetDocumentByKey(Lcase(personName), True)

instead of

Set viewNames = dbNames.GetView(“($VIMPeople)”)

Set docNames=viewNames.GetDocumentByKey(curdoc.GetItemValue(“UserName”)(0), True)

This will give you better hits since it won’t depend on the case or if the user writes a complete user name or just the common name (both versions are available in the view).