Search code examples
lotus-noteslotusscript

lotus script to get register use OU and O?


i am trying to get the OU and O from a user ID which is newly created

TestUser1.id

Question: i want to get full path of the new register ID.

1) Without login to that account to return the user ID Information ?

Full path = CN=TestUser1/OU=Software/O=pcs

Sub Initialize
  Dim session As New NotesSession
  Dim adminp As NotesAdministrationProcess
  Set adminp = _
  session.CreateAdministrationProcess(mailsvr)
  noteid$ = adminp.SetUserPasswordSettings( _
  "CN=TestUsesr1/OU=Software/O=pcs", PWD_CHK_LOCKOUT, 0, 0, True)
  If noteid$<> "" Then
    Dim db As New NotesDatabase(mailsvr, "admin4.nsf")
    Dim ws As New NotesUIWorkspace
    Call ws.EditDocument(False, db.GetDocumentByID(noteid$))
  End If
End Sub

Actually what i really want to do is to force user to first times login an account to force user change his/her http password

i not sure this is the correct way to do it or not for a new created ID?

below link is related with this topic:

force notes user to change password / internet password on next login using lotus script


Solution

  • As already partly answered in your linked question forcing a user to change his internet password is very easy:

    • Get user document from server names.nsf
    • set field HTTPPasswordForceChange to "1"

    Here is some example code (no error handling, not syntax checked). From the documentation your adminp- example should work as well, but it will lockout the user and not allow him to login if the server is configured like to check passwords...

    Dim db as NotesDatabase  
    Dim viwUser as NotesView
    Dim docUser as NotesDocument
    Set db = New NotesDatabase( yourServer, "names.nsf" )
    Set viwUser = db.GetView( "($Users)" )
    Set docUser = viwUser.GetDocumentByKey( "CN=TestUsesr1/OU=Software/O=pcs" )
    Call docUser.ReplaceItemValue( "HTTPPasswordForceChange" , "1" )
    Call docUser.Save( True, True, True )