gruppemedlemskab og nestede grupper
Input:Username
DomainName
GroupName
Ønske:
Script som kan fortælle om brugeren er medlem af gruppen... det skal også virke med nestede grupper.
Nedenstående påståes at virke, men gør det ikke.....
Nogen hints?
anyone
-- script
Function IsMember(strGroup, strUser, strDomain)
Dim objMember, objGroup
On Error Resume Next
' Initialize vars
' Get reference to scanned group, if it can connect, it is a group
Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
' Is the given scanned group really a group? Check error of the line above
If Err.Number = 0 Then
' Is the searched user a direct member of the group? No recursive checking here
IsMember = objGroup.IsMember("WinNT://" & strDomain & "/" & strUser)
If Not IsMember Then
' Search the nesting groups
For Each objMember In objGroup.Members
' Recursive funtion call
IsMember = IsMember(objMember.Name, strUser, strDomain)
' Membership found, exit loop
If IsMember Then Exit For
Next ' For Each objMember In objGroup.Members
End If ' If Not IsMember
Else ' If Err.Number = 0
' Can't search in a user -> no group
IsMember = False
End If ' If Err.Number = 0
On Error Goto 0
End Function