To remove a user from a group, i use:
Public Sub RemoveFromSecGroup(strUserName As String, strGroupName As String)
' remove user from a group
Dim uUser As user
Dim gGroup As Group
Set uUser = DBEngine.Workspaces(0).Users(strUserName)
uUser.Groups.Delete strGroupName
uUser.Groups.Refresh
End Sub
And, to walk the susers groups..you can use:
Dim grp As Group
Dim usr As user
set user = DBEngine.Workspaces(0).Users("Albert")
For Each grp In usr.Groups
if grp.name <> "users" then
call RemoveFromSecGroup("Albert",grp.name)
end if
Next
And, here is a handy fcntion I use to test for in a group
Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName
Dim grp As Group
Dim IIG As Boolean
Dim usr As user
IIG = False
For Each usr In DBEngine.Workspaces(0).Users
For Each usr In DBEngine.Workspaces(0).Users
If usr.Name = UsrName Then GoTo FoundUser
Next
GoTo IIG_Exit
FoundUser:
For Each grp In usr.Groups
If grp.Name = GrpName Then IIG = True
Next
IIG_Exit:
IsInGroup = IIG
End Function