VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Verify group members of an AD/NT group. If the group contains unwanted members, FALSE is returned.

by www.monitortools.com (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 7th September 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Verify group members of an AD/NT group. If the group contains unwanted members, FALSE is returned.

Rate Verify group members of an AD/NT group. If the group contains unwanted members, FALSE is returned.



' This function checks all members of strGroup. If an element of this
' group is not member of the strMemberList, then False is returned. Otherwise,
' True is returned.
' This functions is often used to check if the Domain Admin or Enterpise Admin
' group has no unexpected members.

On Error Resume Next

    Dim objGroup, objUser
    Dim bMemberFound, arrUsers, i

    VerifyGroupMembers = False

    Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
    If( Err.Number <> 0 ) Then
        VerifyGroupMembers = retvalUnknown
        EXPLANATION = "Domain or group not found"
        Exit Function
    End If

    arrUsers = Split( strMemberList, "," )
    
    For Each objUser In objGroup.Members

        If( Err.Number <> 0 ) Then
            VerifyGroupMembers = retvalUnknown
            EXPLANATION = "Unable to list group members"
            Exit Function
        End If

        bMemberFound = False
              
        For i = 0 To UBound( arrUsers )
            If( UCase( Trim( arrUsers(i) ) ) = UCase( Trim( objUser.Name ) ) ) Then
                bMemberFound = True
                Exit For
            End If
     Next
    
     If( Not bMemberFound ) Then
         VerifyGroupMembers = False
            EXPLANATION = "User '" & objUser.Name & "' is not allowed to be member of group '" & strGroup & "'"
         Exit Function
     End If
    Next
    
    VerifyGroupMembers = True
    EXPLANATION = "All members of group '" & strGroup & "' are allowed members"
End Function

Download this snippet    Add to My Saved Code

Verify group members of an AD/NT group. If the group contains unwanted members, FALSE is returned. Comments

No comments have been posted about Verify group members of an AD/NT group. If the group contains unwanted members, FALSE is returned.. Why not be the first to post a comment about Verify group members of an AD/NT group. If the group contains unwanted members, FALSE is returned..

Post your comment

Subject:
Message:
0/1000 characters