Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to list available domain controllers


2 replies to this topic

timesite

timesite
  • Full Members
  • 3 posts

Posted 21 July 2007 - 03:23

We need to identify the available domain controllers on a network, we are trying to use GetObject("LDAP://rootDSE") but are not getting anywhere. Any help or pointers would be greatly appreciated.

Holger_G

Holger_G
  • Full Members
  • 155 posts

Posted 26 July 2007 - 13:09

Try this.....

#define ADS_SCOPE_SUBTREE 2

OBJECT objRootDSE;
OBJECT objConnection;
OBJECT objCommand;
OBJECT objRecordSet;
OBJECT objParent;
OBJECT objFields;
STRING szConfigurationNC;

set objRootDSE = CoGetObject("LDAP://RootDSE", "");
szConfigurationNC = objRootDSE.Get("configurationNamingContext");
set objConnection = CreateObject("ADODB.Connection");
set objCommand = CreateObject("ADODB.Command");
objConnection.Provider = "ADsDSOObject";
objConnection.Open("Active Directory Provider");
set objCommand.ActiveConnection = objConnection;

objCommand.Properties("Page Size") = 1000;
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE;

objCommand.CommandText = "SELECT ADsPath FROM 'LDAP://" + szConfigurationNC + "' WHERE objectClass='nTDSDSA'";
set objRecordSet = objCommand.Execute;

objRecordSet.MoveFirst;
repeat
set objFields = CoGetObject(objRecordSet.Fields("ADsPath"), "");
set objParent = CoGetObject(objFields.Parent, "");
SprintfBox (INFORMATION, "", "Domain: %s", objParent.CN);
objRecordSet.MoveNext;
until objRecordSet.EOF;


Hope that helps
-Nick

timesite

timesite
  • Full Members
  • 3 posts

Posted 01 August 2007 - 11:51

Thanks very much - have not tried it yet, will post results when we have some.

Simon