Microsoft KB Archive/124240

= ACC2: Only Admins Group Members Can List Groups They Belong To =

Article ID: 124240

Article Last Modified on 1/26/2005

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q124240



SYMPTOMS
Advanced: Requires expert coding, interoperability, and multiuser skills.

You can use Access Basic code to determine to which groups a user belongs, but only members of the Admins group can view this information. For example, running the following sample function will return the current user's name and a list of the groups to which the current user belongs:

Function GetGroups Dim W As WorkSpace, US As String, U As User, i As Integer, j As Integer

Set W = DBEngine.Workspaces(0) US = CurrentUser Set U = W.Users(US)

Debug.Print U.Name For j = 0 To U.Groups.Count - 1 Debug.Print "  " & U(j).Name Next

End Function

If the current user is not a member of the Admins group, the following error message will be generated:

Record(s) can't be read; no Read Data permissions on 'MSysGroups'



RESOLUTION
To work around this behavior, you must log in to a new workspace as a member of the Admins group and pass the name of the user whose groups you want to list. The following sample function demonstrates this method:

Function GetGroups2 Dim W As WorkSpace, US As String, U As User, i As Integer

Set W = DBEngine.CreateWorkspace("NewWS", "MyAdmin", "MyPassword") US = CurrentUser Set U = W.users(US)

Debug.Print U.Name For i = 0 To U.Groups.Count - 1 Debug.Print "  " & U(i).Name Next

End Function

NOTE: This function assumes the existence of a user named MyAdmin who is a member of the Admins group in the current system database with an account password of MyPassword.



STATUS
This behavior no longer occurs in Microsoft Access version 7.0.

