VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



VBScript/ADSI sample - checks all members of a group. If an element of this group is not member of

by Bart Jonkman (20 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 19th February 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

VBScript/ADSI sample - checks all members of a group. If an element of this group is not member of the a predefined list, then False is

Rate VBScript/ADSI sample - checks all members of a group. If an element of this group is not member of



' 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.

' Check out http://www.activxperts.com for more samples and components


Function VerifyGroupMembers( strDomain, strGroup, strMemberList )

    VerifyGroupMembers = False
    Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")

    arrUsers = Split( strMemberList, "," )
    
    For Each objUser In objGroup.Members
    
        WScript.Echo "Checkiing group member " & objUser.Name
        
        bMemberFound = False
              
        For i = 0 To UBound( arrUsers )
         If( UCase( Trim( arrUsers(i) ) ) = UCase( Trim( objUser.Name ) ) ) Then
         WScript.Echo "Member found: " & objUser.Name
             bMemberFound = True
             Exit For
         End If
     Next
    
     If( Not bMemberFound ) Then
         WScript.Echo "Member NOT found: " & objUser.Name
         VerifyGroupMembers = False
         Exit Function
     End If
    Next
    
    VerifyGroupMembers = True
End Function




' Main

Do
   strDomain = inputbox( "Please enter the domain name.", "Input" )
Loop until strDomain <> ""

Do
   strGroup = inputbox( "Please enter the name of the group you want to check (for instance: Domain Admins).", "Input" )
Loop until strGroup <> ""

Do
   strMembers = inputbox( "Please enter all domain admin members, separated by ','", "Input" )
Loop until strMembers <> "" 

If( VerifyGroupMembers( strDomain, strGroup, strMembers ) = True ) Then
    WScript.Echo "Check successfull"
Else
    WScript.Echo "Check failed"
End If





Download this snippet    Add to My Saved Code

VBScript/ADSI sample - checks all members of a group. If an element of this group is not member of Comments

No comments have been posted about VBScript/ADSI sample - checks all members of a group. If an element of this group is not member of . Why not be the first to post a comment about VBScript/ADSI sample - checks all members of a group. If an element of this group is not member of .

Post your comment

Subject:
Message:
0/1000 characters