Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/250324

From BetaArchive Wiki

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 = "<Enter correct domain name here>"

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


Last Reviewed: February 6, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.