INF: Sample Function to List Groups in System Database
  
PSS ID Number: Q109720
Article last modified on 03-13-1995
 
1.00 1.10 2.00
 
WINDOWS
 

---------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Access versions 1.0, 1.1, and 2.0
---------------------------------------------------------------------
 
SUMMARY
=======
 
This article describes a sample Access Basic function to list the groups in
your Microsoft Access system database.
 
Notes
-----
 
 - The technique described below relies on the use of tables stored with
   your SYSTEM.MDA file. These tables are undocumented and are subject to
   change in future versions of Microsoft Access. Use of the system tables
   is not supported by Microsoft.
 
 - This article assumes that you are familiar with Access Basic and with
   creating Microsoft Access applications using the programming tools
   provided with Microsoft Access. For more information on Access Basic,
   please refer to the "Introduction to Programming" manual in Microsoft
   Access version 1.x, or the "Building Applications" manual in version
   2.0.
 
MORE INFORMATION
================
 
The following function returns a comma-separated list of the groups in your
Microsoft Access system database. The function takes one argument that
specifies the complete path and filename for the SYSTEM.MDA file that you
want to query:
 
1. Add the following code to a new or existing module:
 
      '**********************************
      'Declarations section of the module
      '**********************************
      Option Explicit
 
      '****************************
      'The CurrentGroups() function
      '****************************
      Function CurrentGroups (SysDB As String)
         Dim DB As Database
         Dim DS As Dynaset
         Dim CurrUser As String, Groups As String
         Dim Counter As Integer
 
         Set DB = OpenDatabase(SysDB)
         Set DS = DB.CreateDynaset("MSysGroupList")
 
         DS.MoveLast
         DS.MoveFirst
 
         For Counter = 1 To DS.RecordCount
            Groups = Groups & IIf(Len(Groups) > 0, ",", "") & DS![Name]
            DS.MoveNext
         Next Counter
 
         DS.Close
         DB.Close
 
         CurrentGroups = Groups
 
      End Function
 
2. To call this function on a computer where the SYSTEM.MDA file is located
   in the ACCESS directory on drive C, type the following in the module's
   Immediate window:
 
      ? CurrentGroups("C:\ACCESS\SYSTEM.MDA")
 
   A system that has had no groups added will return the following list:
 
      Admins,Guests,Users
 
NOTE: In Microsoft Access version 2.0, you can use the Print Security
command from the Security menu to get a list of users and groups in the
current system database. You can use the sample function in this article to
list the groups in any other system database.
 
REFERENCES
==========
 
For more information about Microsoft Access security and groups, search for
"security: users/groups" using the Microsoft Access Help menu.
 
Additional reference words: 1.00 1.10 2.00
KBCategory: kbusage
KBSubcategory: ScrtOthr
=============================================================================
Copyright Microsoft Corporation 1995.
