Users.AddEx
This function adds a new User into the collection, and return a new User object (with audit log explanation).
| Syntax | Parameters | Return Value |
|---|---|---|
Function Users.AddEx( _
CreateInfo As UserCreateInfo) As Variant
|
CreateInfo [in]
Information about the user being created. Type: UserCreateInfo |
Variant |
SVB Example
Adding a user:
Sub Main
Dim oOM As ObjectManager
'Reconnect into Enterprise
Set oOM = New ObjectManager
oOM.Reconnect Application
'Set the information for the user
Dim BlakesUserInfo As New UserCreateInfo
BlakesUserInfo.AuditLogReason = "Adding Blake to the system"
BlakesUserInfo.Name = "Blake"
'Use a placeholder password for now
BlakesUserInfo.Password = "MyPassword"
'Add him to the system
Dim NewUser As User
Set NewUser = oOM.Users.AddEx(BlakesUserInfo)
'Stop commits until we are done editing the user
NewUser.AutoSave = False
'Force user to enter a meaningful password when he first logs in.
NewUser.MustChangePassword = True
'Add him to the "Statistician" group and "Administrators" group
NewUser.MemberOf.Add(oOM.Groups.Item("Statistician"))
NewUser.MemberOf.Add(oOM.Groups.Item("Administrators"))
Dim updateInfo As New UserUpdateInfo
updateInfo.AuditLogReason = "Updating user's info"
'commit our changes
NewUser.SaveEx(updateInfo)
'Log in as Blake to set his new password and activate his account.
oOM.Disconnect
End Sub
Copyright © 2020. Cloud Software Group, Inc. All Rights Reserved.
