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?
Thanks...



Help
Back to top








