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 :
- Set fsobj = CreateObject("Scripting.FileSystemObject" )
- Set tf = fsobj.CreateTextFile("C:\script\ADres.txt", True)'crée le fichier ADres
- Dim strPath
- Dim strUsername
- Dim strPassword
- Dim adsNamespaceLDAP
- Dim adsMyObject
- strPath = "LDAP://192.168.1.1/dc=domainname,dc=com"
- strUsername = "cn=Administrateur,cn=Users," & "dc=domainname,dc=com"
- strPassword = "admin"
- Set adsNamespaceLDAP = GetObject("LDAP:" )
- Set adsMyObject = adsNamespaceLDAP.OpenDSObject (strPath, strUsername, strPassword, 0)
- Const ADS_SCOPE_SUBTREE = 2
- Set objConnection = CreateObject("ADODB.Connection" )
- Set objCommand = CreateObject("ADODB.Command" )
- objConnection.Provider = "ADsDSOObject"
- objConnection.Open "Active Directory Provider"
- Set objCommand.ActiveConnection = objConnection
- objCommand.CommandText = _
- "Select Name, Location from 'LDAP://DC=domaine1,DC=fr' " _
- & "where objectClass='computer'"
- objCommand.Properties("Page Size" ) = 1000
- objCommand.Properties("Timeout" ) = 30
- objCommand.Properties("Searchscope" ) = ADS_SCOPE_SUBTREE
- objCommand.Properties("Cache Results" ) = False
- Set objRecordSet = objCommand.Execute
- objRecordSet.MoveFirst
- Do Until objRecordSet.EOF
- tf.Write (objRecordSet.Fields("Name" ).Value &Chr(13)& Chr(10))
- 'Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name" ).Value
- 'Wscript.Echo "Location: " & objRecordSet.Fields("Location" ).Value
- objRecordSet.MoveNext
- Loop
- tf.Close
|
erreur : mot de passe ou utilisateur incorrects!
avec ce code :
Code :
- objConnection.Properties("User ID" ) = userName
- 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