How to change Lotus Domino user's password programmatically using Java?

Hi all,

I am new to Lotus Domino 6.5.4. I need help as I want to change Lotus Domino user’s password programmatically using Java. I tried the following but I am unable to access HTTPPassword field with document object. Kindly let me know if I am doing something wrong here. Below is the my code snippet:-

Session ss = NotesFactory.createSession();

Database dd = ss.getDatabase("abc.xyz.com:63148","names.nsf");

View dv = dd.getView("($Users)");

Document doc = (Document) dv.getAllDocumentsByKey("testuser", true);

doc.HTTPPassword = "newpassword";  // Not working.. :-(

Looking for quick response on this issue. Any pointers on above issue will be highly appreciated.

Thanks & regards,

Sachin

Subject: How to change Lotus Domino user’s password programmatically using Java?

Try doc.replaceItemValue(“HTTPPassword”, “newpassword”)

Subject: RE: How to change Lotus Domino user’s password programmatically using Java?

And I think you also need to call the computeWithForm method right before saving the doc so the translation is run correctly.

Subject: RE: How to change Lotus Domino user’s password programmatically using Java?

An alternative solution would be to calculate the password hash using Evaluate method.

String newpassword=“mynewsecurepassword”;

Vector v = session.evaluate(“@Password("”+newpassword+“")”);

doc.replaceItemValue(“HTTPPassword”, v.firstElement());

doc.save(true, false);

Subject: RE: How to change Lotus Domino user’s password programmatically using Java?

Ah - but he did say Java.

yeah - go for a computeWithDocument - it’ll “hash” the password using the correct technique set up in the directory profile document (strong or weak hashing)

—* Bill

Subject: How to change Lotus Domino user’s password programmatically using Java?

Hi all,

Million thanks for your responses on my issue.

I tried as suggested by Pete. But I am creating a session rather than opening a session. Below is the my code snippet:-

Session ss = NotesFactory.createSession(“abc.xyz.com:63148”,“testuser”,“password”);

// also tried Session ss = NotesFactory.createSession();

Database dd = ss.getDatabase(“abc.xyz.com:63148”,“names.nsf”);

View dv = dd.getView(“($Users)”); //

Document doc = (Document) dv.getAllDocumentsByKey(“testuser”, true);

doc.replaceItemValue(“HTTPPassword”, “newpassword”);

doc.computeWithForm(true, true);

doc.save(true, true);

Below is the error stack trace that I am getting:-

NotesException: Database abc.xyz.com:63148!!names.nsf has not been opened yet

    at lotus.domino.NotesExceptionHelper.read(Unknown Source)

    at lotus.domino.NotesExceptionHolder._read(Unknown Source)

    at lotus.priv.CORBA.iiop.RepImpl.invoke(Unknown Source)

    at lotus.priv.CORBA.portable.ObjectImpl._invoke(Unknown Source)

    at lotus.domino.corba._IDatabaseStub.getView(Unknown Source)

    at lotus.domino.cso.Database.getView(Unknown Source)

    at portlets.LDChangePassword.LDController.changePassword(LDController.jpf:87)

Kindly let me know how to open a session with Lotus Domino. Any comments or suggestion on my implementation will be appreciated.

Thanks and regards,

Sachin

Subject: RE: How to change Lotus Domino user’s password programmatically using Java?

Hi all,

Following code is working fine for me…

Session ss = NotesFactory.createSession(“abc.xyz.com:63148”,“testuser”,“password”);

Database dd = ss.getDatabase(“”,“names.nsf”); // removed first parameter.

View dv = dd.getView(“($Users)”);

Document doc = (Document) dv.getDocumentByKey(“testuser”, true);

doc.replaceItemValue(“HTTPPassword”,“newpassword”);

doc.computeWithForm(true, true);

doc.save(true, true);

But now I am getting…

NotesException: Notes error: You cannot update or delete the document(s) since you are not listed as an allowable Author for this document

at lotus.domino.NotesExceptionHelper.read(Unknown Source)

at lotus.domino.NotesExceptionHolder._read(Unknown Source)

at lotus.priv.CORBA.iiop.RepImpl.invoke(Unknown Source)

at lotus.priv.CORBA.portable.ObjectImpl._invoke(Unknown Source)

at lotus.domino.corba._IDocumentStub.save(Unknown Source)

at lotus.domino.cso.Document.save(Unknown Source)

at lotus.domino.cso.Document.save(Unknown Source)

at portlets.LDChangePassword.LDController.changePassword(LDController.jp f:91)

Any pointers on the above issue?

Regards,

Sachin

Subject: RE: How to change Lotus Domino user’s password programmatically using Java?

I think the error means…

You’re authenticating as “testuser”, and that user does not have access to edit the document. “testuser” must have Editor access to the database, or otherwise have Author access and be listed in the Person document’s “owners” (on last tab).

You should also make sure the database ACL has “maximum internet name and password” set to Author or Editor, depending.