1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
On Error Resume Next
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Set objUser = GetObject ("LDAP://cn=user,OU=Users,OU=machin,OU=machin,DC=machin,DC=emi,DC=machin,DC=machin")
intPrimaryGroupID = objUser.Get("primaryGroupID")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://OU=machin,OU=machin,DC=machin,DC=machin,DC=machin,DC=machin>;(objectCategory=Group);" & "distinguishedName,primaryGroupToken;subtree"
Set objRecordSet = objCommand.Execute
Do Until objRecordset.EOF
If objRecordset.Fields("primaryGroupToken") = intPrimaryGroupID Then
WScript.Echo "Primary group:" 'ne m'affiche que du vide
WScript.Echo objRecordset.Fields("distinguishedName") & " (primaryGroupID: " & intPrimaryGroupID & ")"
End If
objRecordset.MoveNext
Loop
objConnection.Close |