Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1399 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  [VBS]authentification AD

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[VBS]authentification AD

n°1172187
cradle6661
Posté le 08-08-2005 à 10:41:08  profilanswer
 

slt!
je veux récupérer la liste des PCs contenus dans AD d'1 domaine différent.j'ai un prob pour l'authentification:

Code :
  1. Set fsobj = CreateObject("Scripting.FileSystemObject" )
  2. Set tf = fsobj.CreateTextFile("C:\script\ADres.txt", True)'crée le fichier ADres
  3. Dim strPath
  4. Dim strUsername
  5. Dim strPassword
  6. Dim adsNamespaceLDAP
  7. Dim adsMyObject
  8. strPath = "LDAP://192.168.1.1/dc=domainname,dc=com"
  9. strUsername = "cn=Administrateur,cn=Users," & "dc=domainname,dc=com"
  10. strPassword = "admin"
  11. Set adsNamespaceLDAP = GetObject("LDAP:" )
  12. Set adsMyObject = adsNamespaceLDAP.OpenDSObject (strPath, strUsername, strPassword, 0)
  13. Const ADS_SCOPE_SUBTREE = 2
  14. Set objConnection = CreateObject("ADODB.Connection" )
  15. Set objCommand = CreateObject("ADODB.Command" )
  16. objConnection.Provider = "ADsDSOObject"
  17. objConnection.Open "Active Directory Provider"
  18. Set objCommand.ActiveConnection = objConnection
  19. objCommand.CommandText = _
  20. "Select Name, Location from 'LDAP://DC=domaine1,DC=fr' " _
  21. & "where objectClass='computer'"
  22. objCommand.Properties("Page Size" ) = 1000
  23. objCommand.Properties("Timeout" ) = 30
  24. objCommand.Properties("Searchscope" ) = ADS_SCOPE_SUBTREE
  25. objCommand.Properties("Cache Results" ) = False
  26. Set objRecordSet = objCommand.Execute
  27. objRecordSet.MoveFirst
  28. Do Until objRecordSet.EOF
  29. tf.Write (objRecordSet.Fields("Name" ).Value &Chr(13)& Chr(10))
  30. 'Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name" ).Value
  31. 'Wscript.Echo "Location: " & objRecordSet.Fields("Location" ).Value
  32. objRecordSet.MoveNext
  33. Loop
  34. tf.Close


erreur : mot de passe ou utilisateur incorrects!
avec ce code :

Code :
  1. objConnection.Properties("User ID" ) = userName
  2. objConnection.Properties("Password" ) = password


erreur non spécifiée :
Set objRecordSet = objCommand.Execute  
 
quelqu'un pourrait-il m'aider?
merci


Message édité par cradle6661 le 08-08-2005 à 10:43:17
mood
Publicité
Posté le 08-08-2005 à 10:41:08  profilanswer
 

n°1172362
cradle6661
Posté le 08-08-2005 à 13:46:27  profilanswer
 

en mettant userName et password entre "", erreur : demande d'autorisation refusée
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  [VBS]authentification AD

 

Sujets relatifs
[VBS] [Résolu] Libération mémoire d'objet WORD[VBS] [Résolu]Centrer du texte dans un document Word
Protocole d'authentification d'un client auprès d'un serveur[VBS] Comment transformer un vbs en windows mobile smartphone?
[VBS] appel d'une foonction avant fermeture du script[Résolu] concatener+VBS
[VBS] Faire un "File Open Dialog"[VBS] Effacer (Purger) le presse-papiers (clipboard)
[VBS] liste computer dans AD domaine diff[Résolu] Vbs+excel :(
Plus de sujets relatifs à : [VBS]authentification AD


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR