Bonjour a tous et à toutes,
Depuis quelque jours nous avons un problème avec le script en HTA et VBS, nous avons besoin d'ajouté des groupe au utilisateur sans passer par RSAT ou autre Tools .

Le script HTA + VBS fonctionne correctement pour supprimer les groupe de l'utilisateur, mais pas l'inverse, ajouté un utilisateur à un groupe erreur ligne 78.
Avez-vous une idée sur cette erreur?

Screen Erreur

Nom : 65lp.png
Affichages : 35
Taille : 35,0 Ko

Je vous joint le script

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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<html>
<head>
<title>User Manager</title>
<style type="text/css">
body {
	margin:0px;
	background-color:#CBCBCB; /*#F6F6F6;*/
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px;
	color:#595959;
}
h1 {
	font-size:24px;
	font-weight:bold;
	color:#FFFFFF;
	background-color:#2886C8;
	text-align:center;
	border-style:solid;
	border-width:thin;
	border-color:#C9E0F1;
	padding:5px;
}
</style>
</head>
 
<body>
<center>
<table border="0" width="50%">
	<tr>
		<td width="100%" colspan="2">
		<p align="center">Select a group: <select size="1" name="DD_Group">
		<option value="">--Select a Group--</option>
		<option value="LDAP://CN=RDS-USERS01,OU=RemoteDesktop,OU=UsersDomainName,DC=DomainName,DC=lan">RDS-USERS01</option>
		<option value="LDAP://CN=Group 2,OU=ou1,OU=ou2,OU=ou3,OU=ou4,DC=domain,DC=domain,DC=domain,DC=domain">Group 2</option>
		<option value="LDAP://CN=Group 3,OU=ou1,OU=ou2,OU=ou3,OU=ou4,DC=domain,DC=domain,DC=domain,DC=domain">Group 3</option>
		<option value="LDAP://CN=Group 4,OU=ou1,OU=ou2,OU=ou3,OU=ou4,DC=domain,DC=domain,DC=domain,DC=domain">Group 4</option>
		<option value="LDAP://CN=Group 5,OU=ou1,OU=ou2,OU=ou3,OU=ou4,DC=domain,DC=domain,DC=domain,DC=domain">Group 5</option>
		</select>
		<input type="button" value="Go!" name="btn_go" onClick="vbs:GetMembers"></td>
	</tr>
	<tr>
		<td width="50%">
		<p align="center">
<select size="10" name="UserAccounts"></select></td>
		<td width="50%">
		<p align="center">
<select size="10" name="Group"></select></td>
	</tr>
	<tr>
		<td width="50%">
		<p align="center">
<input type="button" value="Add To Group" onClick="AddToGroup"></td>
		<td width="50%">
		<p align="center">
<input type="button" value="Remove From Group" onClick="RemoveFromGroup"></td>
	</tr>
</table>
 
</center>
</body>
 
<SCRIPT Language="VBScript">
 
    Sub Window_Onload
		'get all members of group and put them in the selection box
			Dim arrNames()
			intSize = 0
			dd_group.style.width = 200
			useraccounts.style.width = 200
			group.style.width = 200
 			Set objRootDSE = GetObject("LDAP://RootDSE")
 			strDNSDomain = objRootDSE.Get("defaultNamingContext")
			Set objGroup = GetObject("LDAP://CN=AccountMail-Zimbra01,OU=AccountMail,OU=UsersDomainName," & strDNSDomain)
 
  			Set objDict = CreateObject("Scripting.Dictionary")
 			objDict.Add LCase("Robert Sampson"), 0
 			
				For Each strUser in objGroup.Member
					ReDim Preserve arrNames(intSize)
					If objDict.Exists(LCase(Mid(Split(strUser, ",")(0), 4))) = False Then
						arrNames(intSize) = Mid(Split(strUser, ",")(0), 4) & "|" & strUser
						intSize = intSize + 1
					End If
				Next
	 
				For i = (UBound(arrNames) - 1) to 0 Step -1
					For j= 0 to i
						If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
							strHolder = arrNames(j+1)
							arrNames(j+1) = arrNames(j)
							arrNames(j) = strHolder
						End If
					Next
				Next 
	 
				For Each strUser in arrNames
					Set objOption = Document.createElement("OPTION")
		            objOption.Text = Split(strUser, "|")(0)
		            objOption.Value = Split(strUser, "|")(1)
		            UserAccounts.Add(objOption)
				Next
			
    End Sub
 
	Sub GetMembers
			'get members of selected group and put them in the selection box
			Dim arrNames()
			intSize = 0
			
			strGroup = DD_Group.Value
 
			Set objGroup = GetObject(strGroup)
			
	    	For intOption = 1 To Group.Length
	    		Group.Remove 0
	    	Next
 
			If TypeName(objGroup.Member) = "Empty" Then
				MsgBox "There are no members in the selected group."
			ElseIf TypeName(objGroup.Member) = "String" Then
				Set objOption = Document.createElement("OPTION")
	            objOption.Text = Mid(Split(objGroup.Member, ",")(0), 4)
	            objOption.Value = objGroup.Member
	            Group.Add(objOption)
			Else
				For Each strUser in objGroup.Member
					ReDim Preserve arrNames(intSize)
					arrNames(intSize) = Mid(Split(strUser, ",")(0), 4) & "|" & strUser
					intSize = intSize + 1
				Next
	 
				For i = (UBound(arrNames) - 1) to 0 Step -1
					For j= 0 to i
						If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
							strHolder = arrNames(j+1)
							arrNames(j+1) = arrNames(j)
							arrNames(j) = strHolder
						End If
					Next
				Next 
	 
				For Each strUser in arrNames
					Set objOption = Document.createElement("OPTION")
		            objOption.Text = Split(strUser, "|")(0)
		            objOption.Value = Split(strUser, "|")(1)
		            Group.Add(objOption)
				Next
			End If
	End Sub
	
Sub AddToGroup
	Set objGroup = GetObject(dd_group.Value)
	objGroup.Add "LDAP://" & useraccounts.value
	btn_go.click
End Sub	
 
Sub RemoveFromGroup
	ADS_PROPERTY_DELETE = 4
	Set objGroup = GetObject(dd_group.Value)
	strUser = group.Value
    objGroup.PutEx ADS_PROPERTY_DELETE, "member", Array(strUser)
    objGroup.SetInfo
    Set objGrou = Nothing
	btn_go.click
End Sub
</SCRIPT>
Bonne journées à vous tous .

Je vous remercie.
Cordialement.