by Anonymous (267 Submissions)
Category: Windows System Services
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
ADSI sample - checks all members of strGroup. If an element of this group is not member of the strMemberList, then 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.
' Check out http://www.activexperts.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 ADSI sample - checks all members of strGroup. If an element of this group is not member of the strM. Why not be the first to post a comment about ADSI sample - checks all members of strGroup. If an element of this group is not member of the strM.