Part | Description |
user | An object variable that represents the User object you want to create. |
object | An object variable that represents the Group or Workspace object for which you want to create the new User object. |
name | Optional. A Variant (String subtype) that uniquely names the new User object. See the Name property for details on valid User names. |
pid | Optional. A Variant (String subtype) containing the PID of a user account. The identifier must contain from 4 to 20 alphanumeric characters. See the PID property for more information on valid personal identifiers. |
password | Optional. A Variant (String subtype) containing the password for the new User object. The password can be up to 14 characters long and can include any characters except the ASCII character 0 (null). See the Password property for more information on valid passwords. |
Sub CreateUserX()
Dim wrkDefault As Workspace
Dim usrNew As User
Dim grpNew As Group
Dim usrTemp As User
Dim prpLoop As Property
Dim grpLoop As Group
Set wrkDefault = DBEngine.Workspaces(0)
With wrkDefault
' Create and append new User.
Set usrNew = .CreateUser("NewUser")
usrNew.PID = "AAA123456789"
usrNew.Password = "NewPassword"
.Users.Append usrNew
' Create and append new Group.
Set grpNew = .CreateGroup("NewGroup", "AAA123456789")
.Groups.Append grpNew
' Make the user "NewUser" a member of the
' group "NewGroup" by creating and adding the
' appropriate User object to the group's Users
' collection.
Set usrTemp = _
.Groups("NewGroup").CreateUser("NewUser")
.Groups("NewGroup").Users.Append usrTemp
Debug.Print "Properties of " & usrNew.Name
' Enumerate the Properties collection of NewUser. The
' PID property is not readable.
For Each prpLoop In usrNew.Properties
On Error Resume Next
If prpLoop <> "" Then Debug.Print " " & _
prpLoop.Name & " = " & prpLoop
On Error GoTo 0
Next prpLoop
Debug.Print "Groups collection of " & usrNew.Name
' Enumerate the Groups collection of NewUser.
For Each grpLoop In usrNew.Groups
Debug.Print " " & grpLoop.Name
Next grpLoop
' Delete the new User and Group objects because this
' is a demonstration.
.Users.Delete "NewUser"
.Groups.Delete "NewGroup"
End With
End Sub