Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determine users windows server groups 1

Status
Not open for further replies.

jordanking

Programmer
Sep 8, 2005
351
Hello,

I have a DB that uses the user name of the windows login. What I am wondering is:
is there a way to determine what group a user belongs to, ie Administrators, Custom Groups, etc...

This is in a windows server small business environment.

thanks

.....
I'd rather be surfing
 
jordanking,
Give this a try: thread705-1420301, you can get the Domain and Username using [tt]Environ$()[/tt].

There is also a way to do it by querying LDAP but I can't find the thread so you might try searching by LDAP.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
thanks,

that sent me in the right direction. I already knew how to get the user name, but the post helped me create a function that tests a given username to see if it is a memeber of a supplied group, returning true/false

Code:
Public Function DMS_User_InGroup(strGroup As String, strUser As String) As Boolean
''assumes user is already logged in and this test is to be applied against current user
Dim objIADsUser As IADsUser
Dim objGroup As IADsGroup
Dim strOutput As String

    strOutput = "WinNT://" & Environ("USERDOMAIN") & "/" & strUser & ",User"
    Set objIADsUser = GetObject(strOutput)
    
    For Each objGroup In objIADsUser.Groups
        If strGroup = objGroup.Name Then
            GoTo Exit_Function
        End If
    Next objGroup
    Set objIADsUser = Nothing
    DMS_User_InGroup = False
    Debug.Print "Not in group"
    Exit Function
    
Exit_Function:
    Set objIADsUser = Nothing
    DMS_User_InGroup = True
    Debug.Print "In group"
End Function

.....
I'd rather be surfing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top