HandsOn Listing All Group Accounts

1. Insert a new module and, in the module's Code window, enter the List_Groups procedure as shown below.

Sub List_Groups()

Dim conn As ADODB.Connection Dim cat As ADOX.Catalog Dim grp As New ADOX.Group Dim strDB As String Dim strSysDb As String strDB = "C:\BookProject\SpecialDb.mdb" strSysDb = "C:\BookProject\Security.mdw"

' Open connection to the database using ' the specified system database Set conn = New ADODB.Connection With conn

.Provider = "Microsoft.Jet.OLEDB.4.0" .Properties("Jet OLEDB:System Database") = strSysDb .Properties("User ID") = "Developer" .Properties("Password") = "chapter17" .Open strDB End With

' Open the catalog Set cat = New ADOX.Catalog cat.ActiveConnection = conn For Each grp In cat.Groups Debug.Print grp.Name

Next

Set cat = Nothing

Part II

conn.Close

Set conn = Nothing

MsgBox "See groups listing in the Immediate window." End Sub

Figure 17-14: The names of existing security group accounts are written to the Immediate window by the List_Groups procedure in Hands-On 17-6.

0 0

Post a comment