Bonjour,
aujourd'hui j'ai fait un ptit test pour le taf, lister les personnes qui appartiennent à un groupe.
bien qu'ayant aucune notion en vbscript, j'ai testé quelques trucs et j'ai copié un script déjà existant mais ca passe pas.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Function ObjSidToStrSid(arrSid)
' Function to convert OctetString (byte array) to Decimal string (SDDL) 
Dim strHex, strDec
 
strHex = OctetStrToHexStr(arrSid)
strDec = HexStrToDecStr(strHex)
ObjSidToStrSid = strDec
End Function ' ObjSidToStrSid
 
Function OctetStrToHexStr(arrbytOctet)
' Function to convert OctetString (byte array) to Hex string.
Dim k
 
OctetStrToHexStr = ""
For k = 1 To Lenb(arrbytOctet)
OctetStrToHexStr = OctetStrToHexStr _
& Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
Next
End Function ' OctetStrToHexStr
 
Function HexStrToDecStr(strSid)
 
Const BYTES_IN_32BITS = 4
Const SRL_BYTE = 0
Const IAV_START_BYTE = 2
Const IAV_END_BYTE = 7
Const RID_START_BYTE = 8
Const MSB = 3 'Most significant byte
Const LSB = 0 'Least significant byte
 
Dim arrbytSid, lngTemp, base, offset, i
 
ReDim arrbytSid(Len(strSid)/2 - 1)
 
' Convert hex string into integer array
For i = 0 To UBound(arrbytSid)
arrbytSid(i) = Cint("&H" & Mid(strSid, 2 * i + 1, 2))
Next
 
' Add SRL number
HexStrToDecStr = "S-" & arrbytSid(SRL_BYTE)
 
' Add Identifier Authority Value
lngTemp = 0
For i = IAV_START_BYTE To IAV_END_BYTE
lngTemp = lngTemp * 256 + arrbytSid(i)
Next
HexStrToDecStr = HexStrToDecStr & "-" & CStr(lngTemp)
 
For base = RID_START_BYTE To UBound(arrbytSid) Step BYTES_IN_32BITS
lngTemp = 0
For offset = MSB to LSB Step -1
lngTemp = lngTemp * 256 + arrbytSid(base + offset)
Next
HexStrToDecStr = HexStrToDecStr & "-" & CStr(lngTemp)
Next
End Function ' HexStrToDecStr
 
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("E:\altiris\eXpress\Deployment Server\AD_migration\scripts\liste_groupe_ad_test.txt", ForAppending, True)
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
 
objCommand.Properties("Page Size") = 100000
objCommand.CommandText = _
    "<GC://CN=U_BSDE_PURCH_GROUPE,OU=Bonna Sabla,OU=Groups,dc=cns,dc=concrete,dc=int>;(objectCategory=Groups)" & _
        ";givenname,sn,userprincipalname,objectSid,distinguishedName,sAMAccountName;subtree"  
Set objRecordSet = objCommand.Execute
intCounter = 0
Do Until objRecordset.EOF
 
    usergn=objRecordset.Fields("givenName")
    userna=objRecordset.Fields("sn")
    usermail=objRecordset.Fields("userprincipalname")
    userdn=objRecordset.Fields("distinguishedName")
    useracc=objRecordset.Fields("sAMAccountName")
 
    strsid=ObjSidToStrSid(cstr(objRecordset.Fields("objectSid")))
    WScript.Echo VbCrLf & intCounter & " dans le groupe"	
    intCounter = intCounter + 1
 
    objTextFile.WriteLine(usermail)
    objRecordset.MoveNext
 
Loop
 
WScript.Echo VbCrLf & intCounter & " utilisateur(s) dans le groupe"
 
objTextFile.Close 
objConnection.Close
Il y a surement des choses inutiles dans ce code, je n'ai fais que le reprendre en changeant juste ce qui m'interesse.
Au départ ce script était fais pour chopé les infos utilisateurs d'une OU de l'OU User account

Moi il faut que je chope les noms des personnes qui sont dans une OU de l'OU de Groups.

Je crois que les infos suivantes sont pas adaptées :
Et aussi, je crois qu'il ne rentre dans pas dans ma boucle, il sort toujours " personnes dans le groupe".
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
objCommand.CommandText = _
    "<GC://CN=U_BSDE_PURCH_GROUPE,OU=Bonna Sabla,OU=Groups,dc=cns,dc=concrete,dc=int>;(objectCategory=Groups)" & _
        ";givenname,sn,userprincipalname,objectSid,distinguishedName,sAMAccountName;subtree"
qqn peut-il me donner les bonnes infos ? ou m'éclairer un peu ?

Merci d'avance !