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