MSFN Forum: Reliable IADs/ADSI Method: In a Domain? - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Reliable IADs/ADSI Method: In a Domain? Script needs to know if the computer is in a domain. Rate Topic: -----

#1 User is offline   Phoenix-IT 

  • Group: Members
  • Posts: 5
  • Joined: 21-August 06

Posted 06 April 2008 - 05:09 PM

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


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy