The LotusScript NotesRegistration class provides a way to register new users. The RegisterNewUser method in the class, in addition to properties within the class, are used to accomplish the registration. The RegisterNewUser method can create an ID file for the new user, create a mail file, and add a Person Document to the Domino Directory.
The syntax of the RegisterNewUser method is as follows (see Supporting Information below for additional details):
notesRegistration.RegisterNewUser( lastname$, idfile$, mailserver$ [, firstname$ [, middle$ [, certpw$ [, location$ [, comment$ [, maildbpath$ [, fwddomain$ [, userpw$ [, usertype% [, altname [, altnamelang ]]]]]]]]]]] )
NOTE: The MailServer$ parameter must be passed in full canonical format (such as CN=ServerA/OU=West/O=Widgets). If you attempt to send mail to users who were registered without the MailServer in canonical format, the following error can occur: "No route found to server X/Org from server X/Org: check server and connection documents in Name and Address Book."
The following properties in the NotesRegistration class must be set prior to calling the RegisterNewUser method:
RegistrationServer
CertifierIDFile
IDType
MinPasswordLength
NOTE: Details on each property can be found in the Domino Designer Online Help.
The following sample LotusScript code demonstrates how to use the method. Replace the text in brackets <> with the information specific to your environment. It could potentially be adapted to loop through an array or text file for batch processing.
Dim Session As New NotesSession
Dim db As NotesDatabase
Dim NR As New NotesRegistration
Dim UseridFile As String
Dim Lname As String
Dim Fname As String
Dim MailServer As String
Dim Mlocation As String
Dim UserPassword As String
Dim UserMailPath As String
Dim CertPassword As String
Dim Comment As String
NR.StoreIDinAddressBook = True
NR.CreateMailDB = True
NR.UpdateAddressBook = True
NR.IDType = ID_HIERARCHICAL
'PARAMETERS TO CODE:
NR.Expiration = Now() + (365 * 2)
NR.registrationServer="NotesServer"
NR.certifieridfile = "
"
NR.OrgUnit = ""
MailServer = "" 'Must use full canonical version of name.
FName = ""
MName = ""
LName = ""
UserPassword = ""
UserIDFile = "" 'May also use: =Trim(Left(FName,1)+LName)
UserMailPath = "\" * useridfile
Mlocation = ""
Comment = "This entry added via agent on date x/y/z" 'As desired
CertPassword =
If NR.RegisterNewUser(LName, UserIDFile, MailServer, FName, Mname , CertPassword, MLocation, Comment, UserMailPath, , UserPassword) Then
Msgbox("User was Registered Successfully")
Else
Msgbox("Sorry, User was Not Registered, Please try again")
End If
Supporting Information:
From the Domino Designer Online Help entry on the RegisterNewUser method (of the NotesRegistration class):
RegisterNewUser
Creates a user ID and optionally adds it to a Domino Directory.
Defined in
NotesRegistration
Syntax
variant = notesRegistration.RegisterNewUser( lastname$, idfile$, mailserver$ [, firstname$ [, middle$ [, certpw$ [, location$ [, comment$ [, maildbpath$ [, fwddomain$ [, userpw$ [, usertype% [, altname [, altnamelang ]]]]]]]]]]] )
Parameters
lastname$
String. The last name of the user to be registered.
idfile$
String. The ID file to be created; specify the complete path, for example, c:\notes\data\user.id.
mailserver$
String. The canonical name of the server containing the user's mail file.
firstname$
String. A first name for the user.
middle$
String. A middle initial for the user.
certpw$
String. The password of the certifier ID file.
location$
String. A value for the location field in the Domino Directory record.
comment$
String. A value for the comment field in the Domino Directory record.
maildbpath$
String. The path of the user's mail file relative to the mail directory; for example, mail\jones.nsf.
fwddomain$
String. The forwarding domain for the user's mail file.
userpw$
String. A password for the user ID file.
usertype%
Note: This parameter is new with Release 5.
Constant of type Integer. Indicates the type of client to be created. May be one of the following.
NOTES_DESKTOP_CLIENT (175) Desktop client
NOTES_FULL _CLIENT (176) Default, full client
NOTES_LIMITED_CLIENT (174) Mail client
altname
Note: This parameter is new with Release 5.0.2.
String. An alternate user name.
altnamelang
Note: This parameter is new with Release 5.0.2.
String. The language for the alternate user name. See @Locale in the formula language for a list of language codes.
Usage
Before calling this method, set CertifierIDFile, Expiration (defaults to 2 years from now), IDTyle, and MinPasswordLength.
Change - Expiration now takes default.
Note: The expiration default is new with Release 6.0.3.
Set UpdateAddressBook True to add a Server record to the Domino Directory. Set StoreIDInAddressBook True to attach the ID to the Domino Directory record. These operations can be performed separately with AddUserToAddressBook.
Set OrgUnit to add an organizational unit to the ID name. Optionally set AltOrgUnit and AltOrgUnitLang.
Optionally set IsNorthAmerican and RegistrationLog.
This method acts on the Domino Directory (names.nsf) for the server specified by RegistrationServer, or names.nsf in the local Domino data directory if this property is not set.