bonjour,

j'ai un souci avec mon scripts et j'aimerai savoir ce qui ne va pas merci mon script a pour but de crée des user dans l'AD

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

strName = "jean"
strSearchName = strName & "*"

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
"SELECT AdsPath FROM 'LDAP://dc=pti.local,dc=com' WHERE objectCategory='user' " & _
"AND samAccountName = '" & strSearchName & "'"
Set objRecordSet = objCommand.Execute

intRecordCount = objRecordset.RecordCount
intRecordCount = intRecordCount + 1

If intRecordCount < 10 Then
strNewName = strName & "0" & intRecordCount
Else
strNewName = strName & intRecordCount
End If

Set objOU = GetObject("LDAP://OU=test OU,dc=pti.local,dc=com")
Set objUser = objOU.Create("User", "cn= " & strNewName)
objUser.samAccountName = strNewName
objUser.SetInfo
objUser.SetPassword "password"
objUser.AccountDisabled = False
objUser.SetInfo


j'ai oublier de dire l'extension du fichier est en .vbs
merci beaucoup pour votre aide