[VBS] pb recup computer dans AD

pb recup computer dans AD [VBS] - VB/VBA/VBS - Programmation

Marsh Posté le 22-06-2005 à 09:41:02    

je dois récupérer la liste des ordis dans AD.
voici le script:
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=fabrikam,DC=com' " _
        & "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
    Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name" ).Value
    Wscript.Echo "Location: " & objRecordSet.Fields("Location" ).Value
    objRecordSet.MoveNext
Loop
 
-------------------
mais j'ai une erreur ligne :Set objRecordSet = objCommand.Execute
"le tableau n'existe pas"
j'ai bien évidement remplacé fabrikam par le nom de mon domaine et com par fr (chez moi)
 
qqun a t-ilune idée?
merci
Tsotb

Reply

Marsh Posté le 22-06-2005 à 09:41:02   

Reply

Marsh Posté le 22-06-2005 à 15:24:39    

salut! (ah mais on se connait nan?)
bon j'ai cherché et voilà
 
 
 
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=domaine,DC=com' " _
      & "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
 
    Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name" ).Value
    Wscript.Echo "Location: " & objRecordSet.Fields("Location" ).Value
    objRecordSet.MoveNext
Loop
 
-----------
TsotB

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed