VBscript LDAP authentification
Bonjour
J'essaie depuis 2 jours à me connecter sur un serveur AD en VBS pour manipuler les utilisateurs mais je n' y arrive pas quand j'utilise le code sur le serveur AD ça marche nikel avec ce bout de code:
Code:
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
|
Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strDNSDomain, strPassword
Dim intCounter, intAccValue, intPwdValue
' Bind to Active Directory Domain
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
WScript.Echo strDNSDomain
strContainer = "CN=toto titi,OU=TEST,"
strPassword = "Test123?"
strContainer = strContainer & strDNSDomain
WScript.Echo strContainer
intAccValue = 512
intPwdValue = 0 ' Default is -1
set objUser =GetObject("LDAP://" & strContainer )
If objUser.class="user" then
objUser.SetPassword strPassword
objUser.Put "userAccountControl", intAccValue
objUser.SetInfo
End If
WScript.Echo "Password is " & strPassword & vbCr & _
"UserAccountControl = " & intAccValue & vbCr & "Check " & strContainer
WScript.Quit |
mais dés que j'exécute a distance rien ne marche j'ai essayer de modifier les 2 ligne en rouge par ça
Code:
1 2 3 4 5 6 7
|
strPath = "LDAP://adresse ip/cn=Testpwd,ou=TEST,dc=france,dc=fr"
strUsername = "cn=nomadmin,cn=Users,dc=france,dc=fr"
strPassword1 = "passeadmin"
Set adsNamespaceLDAP = GetObject("LDAP:")
adsMyObject Set = adsNamespaceLDAP.OpenDSObject(strPath, strUsername, strPassword1, 0) |
mais ça ne donne rien
j'ai une erreur au niveau de la derniere ligne du code ci dessus
Je vous remercie d'avance pour votre aide