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

Last reviewed: May 23, 1997
Article ID: Q124240
The information in this article applies to:
  • Microsoft Access version 2.0

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.

REFERENCES

Microsoft Access "Building Applications," version 2.0, Chapter 14, "Securing Your Applications," pages 340-344

For more information about using DAO to Assign or View Permissions, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q112106
   TITLE     : ACC: How to Use DAO to Assign or View Permissions
 

	
	


Keywords : kberrmsg kbusage ScrtPerm
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : kbcode


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.