Поиск компьютеров в Active Directory

qQuery = "<LDAP://dc=domain,dc=com>;(objectCategory=computer)" & _
       ";distinguishedName,name;subtree"

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = oQuery
  
Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("name")
    objRecordSet.MoveNext
Wend

objConnection.Close
Option Explicit
On Error Resume Next

dim qQuery
dim objConnection
dim objCommand
dim objRecordSet

qQuery = "<LDAP://dc=domain,dc=com>;" & _
		"(objectCategory=computer)" & _
       ";distinguishedName,name" & _
       ",operatingSystem" & _
       ",logonCount" & _
       ";subtree"

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = qQuery
Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("name")
    WScript.Echo objRecordSet.Fields("distinguishedName")
    WScript.Echo objRecordSet.Fields("operatingSystem")
    WScript.Echo objRecordSet.Fields("LogonCount")
    objRecordSet.MoveNext
Wend

objConnection.Close
Option Explicit
On Error Resume Next

dim qQuery
dim objConnection
dim objCommand
dim objRecordSet

qQuery = "<LDAP://dc=domain,dc=com>;" & _
		"(objectCategory=computer)" & _
       ";distinguishedName,name" & _
       ",operatingSystem" & _
       ",logonCount" & _
       ";subtree"

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = qQuery
Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("name")
    WScript.Echo objRecordSet.Fields("distinguishedName")
    WScript.Echo objRecordSet.Fields("operatingSystem")
    WScript.Echo objRecordSet.Fields("LogonCount")
    objRecordSet.MoveNext
Wend

objConnection.Close

Также интересно:

Интересное на сайте: 
0
Голосов пока нет

Оставить комментарий