1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Const ADS_PROPERTY_DELETE = 4
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Set objUser = GetObject ("LDAP://CN=" & strCN & "," & strOUsociete & "," & DomainPath)
arrMemberOf = objUser.GetEx("memberOf")
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
WScript.Echo "This account is not a member of any security groups."
WScript.Quit
End If
For Each Group in arrMemberOf
Set objGroup = GetObject("LDAP://" & Group)
objGroup.PutEx ADS_PROPERTY_DELETE, _
"member", Array("CN=" & strCN)
objGroup.SetInfo
Next |