O'Reilly logo

Active Directory, Second Edition by Alistair G. Lowe-Norris, Robbie Allen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manipulating Print Queues and Print Jobs

So far we’ve shown you how to use ADSI to manipulate persistent and dynamic objects, such as shares, sessions, and resources. Now we’re going to examine printer queues and jobs. In this section, we’re going to lead you through creating scripts to do the following:

  • Identify print queues in Active Directory

  • Bind to a print queue[28] and access its properties

  • List the print jobs in a print queue and manipulate them

Tip

All the code in these scripts for managing printers is done using the WinNT provider, so it will work on Windows NT as well as Active Directory. The LDAP searches will not work on Windows NT.

One point before we go on: at the end of Chapter 20, we detail a function called SearchAD. We need to use it now to search Active Directory for the printer’s ADsPath and store it in arrSearchResults(0,0).

Identifying Print Queues in Active Directory

List-Print-Queue.vbs in Example 22-2 is a heavily commented script, so it should be easy to follow.

Example 22-2. List-Print-Queue.vbs identifies print queues in Active Directory

Option Explicit On Error Resume Next '********************************************************************** 'Active Directory path to start the search from '********************************************************************** Const strDomainToSearch = "LDAP://dc=mycorp,dc=com" '********************************************************************** 'Maximizes the Notepad screen when started '********************************************************************** ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required