L
Leif
I'm able to add users to a group using VBA. The code
follows:
Sub AddUserToGroup(addGrp As String)
Dim ws As DAO.Workspace
Dim usr As DAO.User
Dim grp As DAO.Group
If Not IsUserMember(addGrp) Then
Set ws = DBEngine.CreateWorkspace("Temp", "System
User", "System Password")
Set usr = ws.Users(CurrentUser())
Set grp = usr.CreateGroup(addGrp)
usr.Groups.Append grp
Set usr = Nothing
Set grp = Nothing
ws.Close
Set ws = Nothing
DBEngine.Idle
End If
End Sub
addGrp is a string with the group name to be added.
System User belongs to Admins.
It works fine, the problem is the changes don't take
effect until the user logs out/in again. Since I'm using
this in an Autoexec routine I would like the changes to
take effect immediately.
I know I can get it to work using individual tables, as
demonstrated in SECFAQ.DOC. But it would be much cleaner
if I can just Add/Remove users from a group.
Thanks,
Leif
follows:
Sub AddUserToGroup(addGrp As String)
Dim ws As DAO.Workspace
Dim usr As DAO.User
Dim grp As DAO.Group
If Not IsUserMember(addGrp) Then
Set ws = DBEngine.CreateWorkspace("Temp", "System
User", "System Password")
Set usr = ws.Users(CurrentUser())
Set grp = usr.CreateGroup(addGrp)
usr.Groups.Append grp
Set usr = Nothing
Set grp = Nothing
ws.Close
Set ws = Nothing
DBEngine.Idle
End If
End Sub
addGrp is a string with the group name to be added.
System User belongs to Admins.
It works fine, the problem is the changes don't take
effect until the user logs out/in again. Since I'm using
this in an Autoexec routine I would like the changes to
take effect immediately.
I know I can get it to work using individual tables, as
demonstrated in SECFAQ.DOC. But it would be much cleaner
if I can just Add/Remove users from a group.
Thanks,
Leif