Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access Workgroup Security file (2000)

    I have an Access 2000 database that is secured using a Workgroup Security File. Is there a way to capture the user logon id and the group that user belongs to in VBA code?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Access Workgroup Security file (2000)

    The logon id is easy. It is returned by the currentuser() function.
    Groups are more complicated because a user can belong to many groups at once.

    I found some code in a book the other day that lets me check whether a person is a member of a group. I have used it to write the following function to test if the user is a member of the admins group. It uses ADO and requires a reference to the ADO Extension for DDL and Security (ADOX)

    Public Function fnIsAdmin() As Boolean
    Dim cat As ADOX.Catalog
    Dim usr As ADOX.User
    Dim grp As ADOX.Group
    Dim boolInGroup As Boolean
    Dim owner As String
    On Error Resume Next

    Set cat = New ADOX.Catalog
    Set cat.ActiveConnection = CurrentProject.Connection
    Set grp = cat.Groups("Admins")
    boolInGroup = grp.Users(CurrentUser).Name = CurrentUser
    If boolInGroup Then
    fnIsAdmin = True
    Else
    fnIsAdmin = False
    End If
    End Function
    Regards
    John



  3. #3
    New Lounger
    Join Date
    Apr 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Workgroup Security file (2000)

    Thanks, John. I'll try it and let you know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •