1 changed files with 59 additions and 0 deletions
@ -0,0 +1,59 @@ |
|||||||
|
' Создан: Пт 13 сен 2013 14:18:09 |
||||||
|
' Изменён: Сб 14 сен 2013 12:23:26 |
||||||
|
' |
||||||
|
' (c) 2013, Maxim Lihachev, <envrm@yandex.ru> |
||||||
|
' |
||||||
|
' Получение всех принтеров, опубликованных в Active Directory |
||||||
|
' |
||||||
|
|
||||||
|
Const ADS_SCOPE_SUBTREE = 2 |
||||||
|
|
||||||
|
' Подключение к AD |
||||||
|
Set objConnection = CreateObject("ADODB.Connection") |
||||||
|
Set objCommand = CreateObject("ADODB.Command") |
||||||
|
|
||||||
|
objConnection.Provider = "ADsDSOObject" |
||||||
|
objConnection.Open "Active Directory Provider" |
||||||
|
|
||||||
|
Set objCommand.ActiveConnection = objConnection |
||||||
|
|
||||||
|
' Запрос к LDAP |
||||||
|
objCommand.CommandText = "Select printerName, serverName from " & " 'LDAP://DC=tkpt,DC=ru' where objectClass='printQueue'" |
||||||
|
objCommand.Properties("Page Size") = 1000 |
||||||
|
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE |
||||||
|
|
||||||
|
Set objRecordSet = objCommand.Execute |
||||||
|
|
||||||
|
objRecordSet.MoveFirst |
||||||
|
|
||||||
|
' Форматированный вывод |
||||||
|
Set objCmdLib = CreateObject("Microsoft.CmdLib") |
||||||
|
Set objCmdLib.ScriptingHost = WScript.Application |
||||||
|
|
||||||
|
' Массив результирующих строк |
||||||
|
Dim arrResultsArray() |
||||||
|
|
||||||
|
' Начальная строка |
||||||
|
tableRow = 0 |
||||||
|
|
||||||
|
' Формат вывода данных |
||||||
|
arrHeader = Array("Printer name", "Server") |
||||||
|
arrMaxLength = Array(35, 35) |
||||||
|
strFormat = "Table" |
||||||
|
blnPrintHeader = True |
||||||
|
arrBlnHide = Array(False, False) |
||||||
|
strComputer = "." |
||||||
|
|
||||||
|
Do Until objRecordSet.EOF |
||||||
|
' Добавление элемента в массив |
||||||
|
ReDim Preserve arrResultsArray(tableRow) |
||||||
|
info = Array(objRecordSet.Fields("printerName").Value, objRecordSet.Fields("serverName").Value) |
||||||
|
arrResultsArray(tableRow) = info |
||||||
|
tableRow = tableRow + 1 |
||||||
|
|
||||||
|
objRecordSet.MoveNext |
||||||
|
Loop |
||||||
|
|
||||||
|
' Вывод таблицы данных |
||||||
|
objCmdLib.ShowResults arrHeader, arrResultsArray, arrMaxLength, strFormat, blnPrintHeader, arrBlnHide |
||||||
|
|
Loading…
Reference in new issue