I've been looking at a lot of code to allow me to programatically create users and add them to groups. While the code works, I don't completely understand it, and would like some clarification.
1) This may seem obvious to many of you, but just what are Workspaces? I seem them reference in code, but I'm not sure what they are or what you do with them.
2) The code below is a sample of some of the code I have found. It uses the command CreateUser, and then Append. What do each of these commands do? I have been unable to find answers in the Access help files or by searching online. This code is used to create a new user profile, and similar code is used to add a user to a group. (This code is borrowed from a post by JeremyNYC.)
Public Function CreateUser(ByVal sUserName As String) As Boolean
Dim ws As Workspace
Dim usr As User
Dim grpUsers As Group
Dim sSql As String
Dim sPID As String
Dim SPWD As String
Set ws = DBEngine.Workspaces(0)
.
.
.
Set usr = ws.CreateUser(sUserName, sPID, sPWD)
ws.Users.Append usr
.
.
.
I appreciate any insight you can give me into these commands.
Sleep is for people with no caffeine.
1) This may seem obvious to many of you, but just what are Workspaces? I seem them reference in code, but I'm not sure what they are or what you do with them.
2) The code below is a sample of some of the code I have found. It uses the command CreateUser, and then Append. What do each of these commands do? I have been unable to find answers in the Access help files or by searching online. This code is used to create a new user profile, and similar code is used to add a user to a group. (This code is borrowed from a post by JeremyNYC.)
Public Function CreateUser(ByVal sUserName As String) As Boolean
Dim ws As Workspace
Dim usr As User
Dim grpUsers As Group
Dim sSql As String
Dim sPID As String
Dim SPWD As String
Set ws = DBEngine.Workspaces(0)
.
.
.
Set usr = ws.CreateUser(sUserName, sPID, sPWD)
ws.Users.Append usr
.
.
.
I appreciate any insight you can give me into these commands.
![[morning] [morning] [morning]](/data/assets/smilies/morning.gif)