Microsoft KB Archive/250324

{|
 * width="100%"|

HOWTO: Use ADSI to Determine Server Roles

 * }

Q250324

-

The information in this article applies to:


 * Microsoft Active Directory Service Interfaces, version 2.5

-

SUMMARY
This article demonstrates how to use Active Directory Services Interfaces (ADSI) to determine the role of a computer in a Microsoft Windows domain.

MORE INFORMATION
The following code uses the WinNT provider to loop through all computers in the specified domain. It checks the user flags to determine the role of each computer (either a primary domain controller [PDC]/backup domain controller [BDC], or a member server/workstation on the domain).

Dim oDom Dim oComputer Dim oUser Dim lngFlags Dim strDomain

strDomain = ""

Set oDom = GetObject("WinNT://" & strDomain & ",domain")

oDom.Filter = Array("Computer") For Each oComputer in oDom Set oUser = GetObject("WinNT://" & strDomain & "/" & oComputer.Name & "$,user") lngFlags = oUser.Get("UserFlags") And 8192 If lngFlags = 8192 then MsgBox oComputer.Name & " is either a PDC or BDC." Else MsgBox oComputer.Name & " is either a Member server or Workstation." end if Next

Set oUser = Nothing Set oComputer = Nothing Set oDom = Nothing Additional query words:

Keywords : kbADSI kbMsg kbVBp kbGrpDSPlatform _IK

Issue type : kbhowto

Technology : kbAudDeveloper kbADSISearch kbADSI250