Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303

    Unanswered: Is current User in a particular Group?

    I have a mdw file set up with multiple groups and users. The groups have multiple users and any user may be a member of multiple groups.

    If I have a group in mind, is there a quick way to find out whether the current user is a member of a group?

    I can identify the user and loop through all the user's groups, comparing each one, but I was curious if there was a quicker or more eloquent (i.e. the right way) method of doing this.

    thanks
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  2. #2
    Join Date
    Jul 2002
    Location
    Kentucky
    Posts
    46
    You can print out your user and groups from the Tools - User and Group Accounts. See button labeled "Print Users and Groups"

  3. #3
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    This is true, by using the "Print Users and Groups" I can administer who's who, and establish access groups, etc.

    What I would like to do though is prohibit or allow navigation/ access/ or SQL statements in code based on the groups that the current user belongs to.

    For example, if someone in the "engineering group" opens the database and wants to search for engineering related items, I will check to see if he is in the "engineering group" and set the sql statement so he has access. If someone in the "quality group" signs on they should only see quality related info. If a manager signs in, and he belongs to both the "engineering group" and the "quality group" then he should see items pertaining to both.

    Saavy?

    Like I said, I think I'll just have to see who is currently in, loop through all the user's groups, and flag the matches that are pertinent.

    Unless...Does anybody know of a command...Is CurrentUser() a member of GroupName?
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  4. #4
    Join Date
    Jan 2002
    Location
    UK
    Posts
    67
    Public Function GETGROUP(strCurrUser As String, strGrp) As Boolean
    On Error GoTo ErrCode

    Dim cat As New ADOX.Catalog
    Dim Cnn As New ADODB.Connection
    Dim Usr As New ADOX.User
    Dim strUser As String
    GETGROUP = False

    Set Cnn = CurrentProject.Connection
    Set cat = New ADOX.Catalog
    cat.ActiveConnection = Cnn

    strUser = strCurrUser
    Set Usr = cat.Users.Item(strUser)

    strErrMsg = "Checking User Groups"

    For xLoop = 0 To Usr.Groups.Count - 1
    If Usr.Groups.Item(xLoop).Name = strGrp Then
    GETGROUP = True
    Exit For
    End If
    Next xLoop
    Set cat = Nothing

    ExitCode:

    Exit Function

    ErrCode:

    msgbox err.number & err.description
    Resume ExitCode

    End Function

  5. #5
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    Thanks 'xzone.' I'm using Access 97. Could you tell me specifically what references I will need to be able to use for the code to compile and run?
    When I tried it, my current settings of Access references didn't like ...

    Dim cat As New ADOX.Catalog
    Dim Cnn As New ADODB.Connection
    Dim Usr As New ADOX.User
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

Posting Permissions

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