Enumerating Domains in the Windows NT Namespace

   

Enumerating Domains in the Windows NT Namespace

Using ADSI, it is surprisingly simple to obtain the entire list of Windows NT domains in the enterprise. This is performed by binding to the WinNT: namespace identifier, then using a For Each loop to enumerate all the members visible to your machine.

This enumeration process can be especially useful upon initialization of a Visual Basic or Web-based administration application. By allowing the user to choose the target domain from a drop-down combo box, you will reduce typographical errors and increase ergonomic efficiency of the application by eliminating the multiple keystrokes required to enter the name of the domain to be managed. This also allows you to implement more efficient code, as there is little need to perform significant error checking on a target domain that was passed into a function using such an enumeration process.

Enumerating Domains Using Visual Basic

You can display all domains in the Windows NT namespace by using the following Visual Basic code:

 Dim NameSpace as IADsContainer Dim Domain as IADs Set NameSpace = GetObject("WinNT:") For Each Domain in Namespace      Debug.Print Domain.Name Next 

Tip

When implemented upon initialization of a custom administrative application, using the previous code in combination with a drop-down combo box or tree-view control can be an especially effective mechanism to select the domain to be managed .



   
Top


Windows NT. 2000 ADSI Scripting for System Administration
Windows NT/2000 ADSI Scripting for System Administration
ISBN: 1578702194
EAN: 2147483647
Year: 2000
Pages: 194
Authors: Thomas Eck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net