Jump to content

Reliable IADs/ADSI Method: In a Domain?


Recommended Posts

I perform centralized desktop management for a large government organization where there are a lot of disparate Domains and Workgroups. I am writing a VBScript that needs to know if a computer is in A domain. Since I may not know of all the domains involved, I can't do a compare-to-known domains and that guarantee a factual result.

Knowing how to find out if a user or group account is in a domain already. And that it is relatively simple, as shown below...

Dim oGroup, oParent, sResult

Set oGroup = GetObject("WinNT://<groupname>,group")
Set oParent = GetObject(oGroup.Parent)

sResult = oParent.Class

' The returned string determines the source of the user or group.
' "Domain" = A Windows Domain
' "Computer" = A Windows XP/2003/Vista computer.
' "User" = A 2000/NT Computer (odd, but true).

I thought that this would work exactly the same for a computer....

Dim oComputer, oParent, sResult

Set oComputer = GetObject("WinNT://<computername>")
Set oParent = GetObject(oComputer.Parent) ' This will be an IADs Domain Object.

sResult = oParent.Class

' oParent.Name would return a string with a Domain or Workgroup name.
' So, sResult SHOULD contain a class string of Domain or Workgroup.
' But sResult will contain "Domain" regardless of whether or not the
' IADs.Domain object contains a Domain or a Workgroup.

Since this didn't work, I browsed the IADs Class Library and found a method in the IADs.Domain object called "boolean IsWorkgroup()". Thinking I had found the solution I called the method bResult = oParent.IsWorkgroup() and received a runtime error "Not Implemented". I checked MSDN and the description for this method is "No Longer Implemented". So I am back to square one...

So far the only thing that even comes close to what I am looking for is to query WMI - Win32_ComputerSystem and get the "DomainRole". Results for that can include "Standalone Workstation" and "Standalone Server". However, will this information be as reliable/up-to-date as something I can get from ADSI?

Any ideas? :hello:

Thanks...

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...