Difference between revisions of "Microsoft KB Archive/246530"

From BetaArchive Wiki
m (Text replacement - ">" to ">")
m (Text replacement - """ to """)
 
Line 165: Line 165:
 
==== Synchronize Domain Controllers ====
 
==== Synchronize Domain Controllers ====
  
This script triggers a synchronization on "server1," pulling any changes from "server2" that have been recorded for the configuration information (includes sites, subnets, and domain controller data):
+
This script triggers a synchronization on "server1," pulling any changes from "server2" that have been recorded for the configuration information (includes sites, subnets, and domain controller data):
<pre class="codesample">Set DLL=CreateObject(&quot;IADsTools.DCFunctions&quot;)
+
<pre class="codesample">Set DLL=CreateObject("IADsTools.DCFunctions")
Result=DLL.ReplicaSync(&quot;server1&quot;,&quot;cn=configuration,dc=mydomain,dc=com&quot;,&quot;server2&quot;)
+
Result=DLL.ReplicaSync("server1","cn=configuration,dc=mydomain,dc=com","server2")
 
if result=-1 Then
 
if result=-1 Then
     Wscript.Echo &quot;The error returned was: &quot; + DLL.LastErrorText
+
     Wscript.Echo "The error returned was: " + DLL.LastErrorText
 
else
 
else
     Wscript.Echo &quot;The command completed successfully.&quot;
+
     Wscript.Echo "The command completed successfully."
 
end if
 
end if
 
                 </pre>
 
                 </pre>
Line 179: Line 179:
 
Dim NamingContext
 
Dim NamingContext
  
TargetServer=&quot;server1&quot;
+
TargetServer="server1"
SourceServer=&quot;server2&quot;
+
SourceServer="server2"
NamingContext=&quot;cn=configuration,dc=mydomain,dc=com&quot;
+
NamingContext="cn=configuration,dc=mydomain,dc=com"
  
Set DLL=CreateObject(&quot;IADsTools.DCFunctions&quot;)
+
Set DLL=CreateObject("IADsTools.DCFunctions")
 
Result=DLL.ReplicaSync(Cstr(TargetServer),Cstr(NamingContext),Cstr(SourceServer))
 
Result=DLL.ReplicaSync(Cstr(TargetServer),Cstr(NamingContext),Cstr(SourceServer))
 
if result=-1 Then
 
if result=-1 Then
     Wscript.Echo &quot;The error returned was: &quot; + DLL.LastErrorText
+
     Wscript.Echo "The error returned was: " + DLL.LastErrorText
 
else
 
else
     Wscript.Echo &quot;The command completed successfully.&quot;
+
     Wscript.Echo "The command completed successfully."
 
end if
 
end if
 
                 </pre>
 
                 </pre>
 
==== Get the List of Global Catalog Servers in the Enterprise ====
 
==== Get the List of Global Catalog Servers in the Enterprise ====
  
This script uses &quot;server1&quot; as the source of information and gets the list of global catalog servers in the enterprise from it:
+
This script uses "server1" as the source of information and gets the list of global catalog servers in the enterprise from it:
<pre class="codesample">Set DLL=CreateObject(&quot;IADsTools.DCFunctions&quot;)
+
<pre class="codesample">Set DLL=CreateObject("IADsTools.DCFunctions")
Result=DLL.GetGCList(&quot;server1&quot;)
+
Result=DLL.GetGCList("server1")
 
if result=-1 Then
 
if result=-1 Then
     Wscript.echo &quot;The error returned was: &quot; + DLL.LastErrorText
+
     Wscript.echo "The error returned was: " + DLL.LastErrorText
 
else
 
else
     Wscript.echo &quot;The number of Global Catalog servers returned is: &quot; + cstr(result)
+
     Wscript.echo "The number of Global Catalog servers returned is: " + cstr(result)
     wscript.echo &quot;----------------------------------------------------&quot;
+
     wscript.echo "----------------------------------------------------"
 
     for i=1 to Result
 
     for i=1 to Result
 
           'print out the name of each GC server
 
           'print out the name of each GC server
Line 210: Line 210:
  
 
This script contacts each domain controller in a domain and checks for any replication problems. This script combines functions that enumerate the list of domain controllers, enumerate the list of directory partitions on each of those domain controllers, and check the replication status of each directory partition for problems:
 
This script contacts each domain controller in a domain and checks for any replication problems. This script combines functions that enumerate the list of domain controllers, enumerate the list of directory partitions on each of those domain controllers, and check the replication status of each directory partition for problems:
<pre class="codesample">Set DLL=CreateObject(&quot;IADsTools.DCFunctions&quot;)
+
<pre class="codesample">Set DLL=CreateObject("IADsTools.DCFunctions")
 
'read the list of domain controllers
 
'read the list of domain controllers
Result=DLL.DsGetDCList(&quot;server1&quot;,&quot;mydomain.com&quot;,1)
+
Result=DLL.DsGetDCList("server1","mydomain.com",1)
 
if result=-1 Then
 
if result=-1 Then
     Wscript.echo &quot;The error returned was: &quot; + DLL.LastErrorText
+
     Wscript.echo "The error returned was: " + DLL.LastErrorText
 
else
 
else
     Wscript.echo &quot;The number of Domain Controllers returned is: &quot; + cstr(result)
+
     Wscript.echo "The number of Domain Controllers returned is: " + cstr(result)
     wscript.echo &quot;--------------------------------------------------&quot;
+
     wscript.echo "--------------------------------------------------"
 
     for i=1 to Result
 
     for i=1 to Result
 
           'for each domain controller, get the number of Directory Partitions (non-partial) it hosts
 
           'for each domain controller, get the number of Directory Partitions (non-partial) it hosts
           wscript.echo &quot;Checking domain controller: &quot; + DLL.DCListEntryNetBiosName(i)
+
           wscript.echo "Checking domain controller: " + DLL.DCListEntryNetBiosName(i)
 
           PartitionResult=DLL.GetNamingContexts(DLL.DCListEntryNetBiosName(i))
 
           PartitionResult=DLL.GetNamingContexts(DLL.DCListEntryNetBiosName(i))
 
           'if we couldn't reach the server, skip it
 
           'if we couldn't reach the server, skip it
 
           if PartitionResult=-1 then
 
           if PartitionResult=-1 then
               wscript.echo &quot;Could not reach the server: &quot; + DLL.DCListEntryNetBiosName(i)
+
               wscript.echo "Could not reach the server: " + DLL.DCListEntryNetBiosName(i)
 
           else
 
           else
               wscript.echo &quot;Found &quot; + CStr(PartitionResult) + &quot; Directory Partitions (non-partial) on (&quot; + DLL.DCListEntryNetBiosName(i) + &quot;).&quot;
+
               wscript.echo "Found " + CStr(PartitionResult) + " Directory Partitions (non-partial) on (" + DLL.DCListEntryNetBiosName(i) + ")."
 
               'query the status of each directory partition
 
               'query the status of each directory partition
 
               for j=1 to PartitionResult
 
               for j=1 to PartitionResult
Line 233: Line 233:
 
                     for k=1 to ReplResult
 
                     for k=1 to ReplResult
 
                         if DLL.DirectPartnerFailReason(k) > 0 then
 
                         if DLL.DirectPartnerFailReason(k) > 0 then
                               wscript.echo &quot;Failure detected replicating partition (&quot; + DLL.NamingContextName(j) + &quot;) from (&quot; + DLL.DirectPartnerName(k) + &quot;).&quot;
+
                               wscript.echo "Failure detected replicating partition (" + DLL.NamingContextName(j) + ") from (" + DLL.DirectPartnerName(k) + ")."
 
                         else
 
                         else
 
                               'if you wanted to enable the following line, you could see the ones that are OK as well
 
                               'if you wanted to enable the following line, you could see the ones that are OK as well
                               'wscript.echo &quot;OK --- Replicating partition (&quot; + DLL.NamingContextName(j) + &quot;) from (&quot; + DLL.DirectPartnerName(k) + &quot;).&quot;
+
                               'wscript.echo "OK --- Replicating partition (" + DLL.NamingContextName(j) + ") from (" + DLL.DirectPartnerName(k) + ")."
 
                         end if
 
                         end if
 
                     next
 
                     next

Latest revision as of 13:50, 21 July 2020

Article ID: 246530

Article Last Modified on 3/1/2007



APPLIES TO

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows 2000 Datacenter Server



This article was previously published under Q246530

SUMMARY

Iadstools.dll is a dynamic-link library (DLL) that you can use to write Microsoft Visual Basic scripts (or create your own programs) to extract specific types of data from Active Directory and to take advantage of new application programming interface (API) calls that are available in Windows 2000. For example, Iadstools.dll includes functions that make it easy to script replication between domain controllers with just a few lines of VBScript code.

Iadstools.dll is installed with the Windows 2000 Support Tools package, which you can install from the Support\Tools folder on the Windows 2000 Server or Professional CD-ROM. For a complete list of all the functions available in Iadstools.dll, see the Iadstools.doc file that is installed with the Windows 2000 Support Tools package.

MORE INFORMATION

Description of the Functions

DsGetDcName: The new Windows 2000 API that allows finding Windows NT 4.0-based and Windows 2000-based domain controllers with varying requirements and much more flexibility.

ReplicaSync: Initiates replication between two domain controllers for a given directory partition.

ReplicaSyncAll: Initiates replication to bring a specific domain controller up to date in respect to all other domain controllers or to push changes from one domain controller to all others.

TriggerKCC: Triggers the Knowledge Consistency Checker (KCC) on the specified server to check the current topology to ensure that it has accounted for any recent changes.

GetGCList: Generates a list of the global catalog servers in the enterprise.

GetDirectPartnersEx: Returns the name and status of the direct replication partners of the specified domain controller.

GetReplicationUSNStateEx: Returns the name and update sequence number (USN) of direct and transitive replication partners.

GetChangeNotifications: Returns the domain controllers that the specified server notifies when changes have occurred that need to be replicated.

GetRidPoolFSMO: Queries the server specified for what it believes is the RID Pool FSMO owner.

GetDomainNamingFSMO: Queries the server specified for what it believes is the Domain Tree Management FSMO owner.

GetSchemaFSMO: Queries the server specified for what it believes is the Schema FSMO owner.

GetPDCFSMO: Queries the server specified for what it believes is the PDC FSMO owner.

GetInfrastructureFSMO: Queries the server specified for what it believes is the Infrastructure FSMO owner.

GetHighestCommittedUSN: Given a domain controller, it receives the highest USN committed for the server.

GetGPOs: Enumerates the Group Policy objects (GPOs) for a given domain controller.

GetGPOVersion: Determines the version of a specific GPO in Active Directory on a particular domain controller.

GetGPOSysVolVersion: Determines the version of a specific GPO in SYSVOL on a particular domain controller.

GetConfigurationNamingContext: Determines the name of the Configuration directory partition for a given domain controller.

GetDefaultNamingContext: Determines the name of the default directory partition (domain) for a given domain controller.

GetMetaData: Returns the attribute metadata for a specific object in Active Directory.

GetDSAConnections: Generates a list of NTDS Connection objects and their properties for a given server.

GetSiteList: Generates a list of the sites given a server from which to source the data.

GetSiteLinks: Generates a list of the site links given a server from which to source the data.

GetSiteLinkBridges: Generates a list of the Site Link Bridges given a server from which to source the data.

GetSiteLinkBridgeProperties: Queries Active Directory for the configuration of a given Site Link Bridge.

GetSiteLinkProperties: Queries Active Directory for the configuration of a given Site Link.

GetSiteProperties: Queries Active Directory for the configuration of a given site.

GetInterSiteTransports: Queries Active Directory for the configuration of IP and SMTP Active Directory replication transports.

GetSiteForServer: Resolves the site of which the specified domain controller is a member.

GetBridgeHeadsInSite: Enumerates the domain controllers acting as bridgeheads in a given site.

GetInterSiteTopologyGenerator: Given a site, gets the single-part name (from the distinguished name) of the computer that owns the role of creating/maintaining the inter-site connection objects for all servers in a site.

DsGetSiteName: The new Windows 2000 API for finding out the site of the computer queried for.

GetSubnets: Queries Active Directory for an enumeration and configuration of subnets.

GetServersInSite: Enumerates the domain controllers in a given site.

GetTrustRelationships: Returns the configuration of the trust relationships for the domain in which the domain controller connected to resides.

GetDSAProperties: Queries Active Directory for the configuration of a particular domain controller's NTDS settings.

DsGetDcList: Gets the list of domain controllers and associated properties for a given domain.

GetIPConfiguration: Determines the IP configuration (including IP address, DNS, etc.) of the server specified.

GetServersInSiteWithWritableNC: Enumerates the domain controllers in a given site with a given writeable directory partition.

GetNamingContexts: Reads the RootDSE of a specified domain controller to determine the directory partitions that it maintains.

GetWritableNCsForServer: Reads the RootDSE of a specified domain controller to determine the directory partitions that it maintains.

GetPartialNamingContexts: Reads the RootDSE of a specified domain controller to determine the partial copy directory partitions that it maintains.

ConvertErrorMsg: Converts an error number to message text.

GetActiveDirectoryProperties: Queries Active Directory for general configuration parameters.

GetRegistryData: Retrieves a registry value from a remote or local computer.

GetServerFromGuid: Resolves a server name from a specified Globally Unique ID (GUID).

GetGuidForServer: Queries Active Directory for the GUID (database GUID) of a given server.

GetObjectGuidForServer: Queries Active Directory for the object GUID of a given server.

GetObjectFromGuid: Resolves an object in Active Directory from a specified object GUID.

TranslateDNToNT4: Converts the distinguished name of a user account (cn=administrator,cn=users,...) to a Windows NT 4.0-style domain\user format (achieved by ADSI).

TranslateNT4ToDN: Converts Windows NT 4.0-style credentials (domain\user) to a distinguished name by looking up the account and reading the distinguished name that identifies that object (achieved by ADSI).

GetPerformanceData: Reads the current value of the counters loaded in InitPerformanceData.

Examples

Synchronize Domain Controllers

This script triggers a synchronization on "server1," pulling any changes from "server2" that have been recorded for the configuration information (includes sites, subnets, and domain controller data):

Set DLL=CreateObject("IADsTools.DCFunctions")
Result=DLL.ReplicaSync("server1","cn=configuration,dc=mydomain,dc=com","server2")
if result=-1 Then
     Wscript.Echo "The error returned was: " + DLL.LastErrorText
else
     Wscript.Echo "The command completed successfully."
end if
                

If you use variables in your script, it looks slightly different:

Dim TargetServer
Dim SourceServer
Dim NamingContext

TargetServer="server1"
SourceServer="server2"
NamingContext="cn=configuration,dc=mydomain,dc=com"

Set DLL=CreateObject("IADsTools.DCFunctions")
Result=DLL.ReplicaSync(Cstr(TargetServer),Cstr(NamingContext),Cstr(SourceServer))
if result=-1 Then
     Wscript.Echo "The error returned was: " + DLL.LastErrorText
else
     Wscript.Echo "The command completed successfully."
end if
                

Get the List of Global Catalog Servers in the Enterprise

This script uses "server1" as the source of information and gets the list of global catalog servers in the enterprise from it:

Set DLL=CreateObject("IADsTools.DCFunctions")
Result=DLL.GetGCList("server1")
if result=-1 Then
     Wscript.echo "The error returned was: " + DLL.LastErrorText
else
     Wscript.echo "The number of Global Catalog servers returned is: " + cstr(result)
     wscript.echo "----------------------------------------------------"
     for i=1 to Result
          'print out the name of each GC server
          wscript.echo DLL.GCName(i)
     next
end if
                

Enumerate Domain Controllers and Check for Replication Problems

This script contacts each domain controller in a domain and checks for any replication problems. This script combines functions that enumerate the list of domain controllers, enumerate the list of directory partitions on each of those domain controllers, and check the replication status of each directory partition for problems:

Set DLL=CreateObject("IADsTools.DCFunctions")
'read the list of domain controllers
Result=DLL.DsGetDCList("server1","mydomain.com",1)
if result=-1 Then
     Wscript.echo "The error returned was: " + DLL.LastErrorText
else
     Wscript.echo "The number of Domain Controllers returned is: " + cstr(result)
     wscript.echo "--------------------------------------------------"
     for i=1 to Result
          'for each domain controller, get the number of Directory Partitions (non-partial) it hosts
          wscript.echo "Checking domain controller: " + DLL.DCListEntryNetBiosName(i)
          PartitionResult=DLL.GetNamingContexts(DLL.DCListEntryNetBiosName(i))
          'if we couldn't reach the server, skip it
          if PartitionResult=-1 then
               wscript.echo "Could not reach the server: " + DLL.DCListEntryNetBiosName(i)
          else
               wscript.echo "Found " + CStr(PartitionResult) + " Directory Partitions (non-partial) on (" + DLL.DCListEntryNetBiosName(i) + ")."
               'query the status of each directory partition
               for j=1 to PartitionResult
                    ReplResult=DLL.GetDirectPartnersEx(DLL.DCListEntryNetBiosName(i),DLL.NamingContextName(j), 0)
                    'see if there's a failure code other than zero for any of the replication partners
                    for k=1 to ReplResult
                         if DLL.DirectPartnerFailReason(k) > 0 then
                              wscript.echo "Failure detected replicating partition (" + DLL.NamingContextName(j) + ") from (" + DLL.DirectPartnerName(k) + ")."
                         else
                              'if you wanted to enable the following line, you could see the ones that are OK as well
                              'wscript.echo "OK --- Replicating partition (" + DLL.NamingContextName(j) + ") from (" + DLL.DirectPartnerName(k) + ")."
                         end if
                    next
                next
          end if
     next
end if
                

Keywords: kbinfo KB246530