Voila, j'ai déja trouvé un script qui faisait tout ce que je voulais c'est à dire, lister les utilisateurs d'un groupe de la AD et l'enregistre dans un fichier csv.
Mais voila je n'arrive pas à introduire mon domaine (LDAP) dedans en fait je ne sais pas ou la mettre : LDAP://DC=D11130100,DC=cpam-marseille,DC=cnamts,DC=fr
Voici le script :
Merci pour votre futur aide.
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
95 const FileName = "groupmembers.csv" groupName = inputbox("Please enter the name of the group:") if groupName = "" then wscript.quit end if groupPath = getgrouppath(groupName) if groupPath = "" then wscript.echo "Unable to find the specified group in the domain" wscript.quit end if set objGroup = getobject(grouppath) set objFSO = createobject("scripting.filesystemobject") set objFile = objFSO.createtextfile(FileName) q = """" objFile.WriteLine(q & "sAMAccountName" & q & "," & q & "Surname" & q & "," & q & "FirstName" & q) for each objMember in objGroup.Members objFile.WriteLine(q & objmember.samaccountname & q & "," & q & objmember.sn & _ q & "," & q & objmember.givenName & q) next '***** Users who's primary group is set to the given group need to be enumerated seperatly.***** getprimarygroupmembers groupname objFile.Close wscript.echo "Completed" function getGroupPath(byval GroupName) set cmd=createobject("ADODB.Command") set cn=createobject("ADODB.Connection") set rs=createobject("ADODB.Recordset") cn.open "Provider=ADsDSOObject;" cmd.commandtext = "SELECT adspath from 'LDAP://" & getnc & _ "' WHERE objectCategory = 'Group' and sAMAccountName = '" & groupname & "'" cmd.activeconnection = cn set rs = cmd.execute if rs.bof <> true and rs.eof<>true then getgrouppath=rs(0) else getgrouppath = "" end if cn.close end function function getNC set objRoot=getobject("LDAP://RootDSE") getNC=objRoot.get("defaultNamingContext") end function function getPrimaryGroupMembers(byval GroupName) set cn = createobject("ADODB.Connection") set cmd = createobject("ADODB.Command") set rs = createobject("ADODB.Recordset") cn.open "Provider=ADsDSOObject;" cmd.activeconnection=cn '***** Change the Page Size to overcome the 1000 record limitation ***** cmd.properties("page size")=1000 cmd.commandtext = "SELECT PrimaryGroupToken FROM 'LDAP://" & getnc & _ "' WHERE sAMAccountName = '" & GroupName & "'" set rs = cmd.execute if rs.eof<>true and rs.bof<>true then PrimaryGroupID = rs(0) else Err.Raise 5000, "getPrimaryGroupMembers", "Unable to find PrimaryGroupToken property" end if cmd.commandtext = "SELECT samaccountname, sn, givenName FROM 'LDAP://" & getNC & _ "' WHERE PrimaryGroupID = '" & PrimaryGroupID & "'" set rs = cmd.execute while rs.eof<>true and rs.bof<>true objFile.WriteLine(q & rs("samaccountname") & q & "," & q & rs("sn") & q & _ "," & q & rs("givenName") & q) rs.movenext wend cn.close end function
Partager