Microsoft KB Archive/901051

= Errors occur after you install the Microsoft Operations Manager 2005 Active Directory Management Pack in a Windows 2000 forest =

Article ID: 901051

Article Last Modified on 1/26/2007

-

APPLIES TO


 * Microsoft Operations Manager (MOM) 2005

-





SYMPTOMS
When you use the Active Directory Management Pack for Microsoft Operations Manager (MOM) 2005 to monitor a native Microsoft Windows 2000 Active Directory environment, you may receive an alert in the MOM Operator console that resembles the following:

An error occurred while executing 'AD Topology Discovery' The query '(&(objectCategory=crossRef)(!(|(cn=Enterprise Schema)(cn=Enterprise Configuration))));ncName,dnsRoot,msDS-NC-Replica-Locations;subtree' failed to execute. The error returned was: 'Unspecified error' (0x80004005) 0x80004005

Additionally, the following MOM Active Directory Management Pack reports may contain no data:
 * AD Domain Changes
 * AD Domain Controllers
 * AD Replication Connection Objects
 * AD Replication Latency Report
 * AD Role Holders
 * AD DC Disk Space Chart
 * DC Replication BW

Note The DC Replication subreport may also contain no data. Additionally, the following reports return no data in a pure Windows 2000 forest:
 * AD Machine Account Authentication Failures
 * AD Replication Site links



CAUSE
This problem occurs when you use MOM 2005 together with version 05.0.2642.0063 of the Active Directory Management Pack to monitor a forest of Windows 2000-based domain controllers. In this scenario, the AD Topology Discovery script may fail because of a dependency on an attribute that exists only in a Microsoft Windows Server 2003 Active Directory environment.



RESOLUTION
To resolve this problem, install the following ADTopologyScriptNew.txt script. This updated version of the AD Topology Discovery script removes a dependency on Microsoft Windows Server 2003. Therefore, the script can run successfully in a native Windows 2000 environment. To install the script, follow the steps in the &quot;Script installation information&quot; section that follows the script.

ADTopologyScriptNew.txt '************************************************************************* ' Script Name - AD Topology Discovery ' ' Purpose    - Discovers the AD Replication Topology and writes it to the '              MOM database '              ' Parameters  - LogSuccessEvent - True/False value to indicates to log an '                                 an event for script success '                                (useful for demos and debugging) ' ' (c) Copyright 2003, Microsoft Corporation, All Rights Reserved ' Proprietary and confidential to Microsoft Corporation '*************************************************************************

Option Explicit

'Event Constants Const EVENT_TYPE_SUCCESS = 0 Const EVENT_TYPE_ERROR = 1 Const EVENT_TYPE_WARNING = 2 Const EVENT_TYPE_INFORMATION = 4

' Event ID Constants Const EVENT_ID_INVALID_PARAM = 20066 Const EVENT_ID_SCRIPT_ERROR = 21000 Const EVENT_ID_SUCCESS = 20099 Const EVENT_ID_NOT_AN_EVENT = 20002 Const EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE = 24000 Const EVENT_ID_AGENTLESS = 20098

' Other Constants Const SCRIPT_NAME = &quot;AD Topology Discovery&quot; Const E_INVALIDARG = &H80070057

Class Error Public Description Public Number Public Source Sub Init(oErr) Description = oErr.Description Number = oErr.Number Source = oErr.Source End Sub Sub Raise(strDescription) Err.number = Number Err.Description = Description Err.Raise Number, Source, strDescription & GetErrorString(Err) End Sub End Class

Dim oError Set oError = new Error On Error Resume Next

If Not(ScriptContext.IsTargetAgentless) Then DoADDiscovery

If Err <> 0 Then CreateEvent EVENT_ID_SCRIPT_ERROR, _ EVENT_TYPE_WARNING, _ &quot;An error occurred while executing '&quot; & SCRIPT_NAME & &quot;'&quot; & _ vbCrLf & Err.Description & vbCrLf & &quot;0x&quot; & Hex(Err.number) End If Else CreateEvent EVENT_ID_AGENTLESS, EVENT_TYPE_ERROR, &quot;The AD Management Pack does not support the agentless management mode.&quot; & vbCrLf & _ &quot;The script '&quot; & SCRIPT_NAME & &quot;' will not execute.&quot; & vbCrLf & _ &quot;To prevent this alert being generated again, either change the monitoring &quot; & _ &quot;mode of the computer '&quot; & ScriptContext.TargetFQDNComputer & &quot;' to agent-managed &quot; & _ &quot;or disable the rule that generated this alert.&quot; End If

' Globals access throughout the script Dim oADOConn, oRootDSE, oOOMADS

Sub DoADDiscovery On Error Resume Next Dim dtStart dtStart = Now

Dim oDiscData Set oDiscData = ScriptContext.CreateDiscoveryData oDiscData.ScopeID = &quot;{69A2FFDA-8F08-415E-A609-B1F42F69B7EA}&quot; ' Create the forests collection Dim oForestsCollection Set oForestsCollection = oDiscData.CreateCollection oForestsCollection.ClassID = &quot;Forest&quot;

' Create the sites collection Dim oSitesCollection Set oSitesCollection = oDiscData.CreateCollection oSitesCollection.ClassID = &quot;Site&quot; oSitesCollection.AddScopeProperty &quot;ISTG Role Holder&quot; oSitesCollection.AddScopeProperty &quot;ISTG Enabled&quot; oSitesCollection.AddScopeProperty &quot;Subnets&quot;

' create collection for AD Site Link Dim oSiteLinkCollection Set oSiteLinkCollection = oDiscData.CreateCollection oSiteLinkCollection.ClassID= &quot;AD Site Link&quot; oSiteLinkCollection.AddScopeProperty &quot;Replicates Every&quot; oSiteLinkCollection.AddScopeProperty &quot;Transport&quot; oSiteLinkCollection.AddScopeProperty &quot;Cost&quot; ' create relationship collection for site to bridgehead Dim oSiteBridgeheadCollection Set oSiteBridgeheadCollection = oDiscData.CreateRelationshipCollection oSiteBridgeheadCollection.TypeID= &quot;Site-Bridgehead&quot; ' create relationship Group to Computer Dim oGroupToComputerCollection Set oGroupToComputerCollection = oDiscData.CreateRelationshipCollection oGroupToComputerCollection.TypeID= &quot;Group-Computer&quot; oGroupToComputerCollection.SourceScopeFilter.AddKeyProperty &quot;GroupName&quot;,&quot;Windows Domain Controllers&quot;

' Create a GCs relationship collection with global scope Dim oGCCollection Set oGCCollection = oDiscData.CreateRelationshipCollection oGCCollection.TypeID = &quot;Computer-GC&quot;

'Add the Forest instance collection to the discovery data packet oDiscData.AddCollection oForestsCollection

'Add the Site instance collection to the discovery data packet oDiscData.AddCollection oSitesCollection

'Add the SiteToSite Relationship collection to the discovery data packet oDiscData.AddCollection oSiteLinkCollection 'Add the GroupToComputer Relationship collection to the discovery data packet oDiscData.AddCollection oGroupToComputerCollection

' Add the collection containing the GC relationships oDiscData.AddCollection oGCCollection Set oOOMADs = CreateObject(&quot;McActiveDir.ActiveDirectory&quot;) If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to CreateObject 'OOMADs'.&quot; End If   Set oADOConn = CreateObject(&quot;ADODB.Connection&quot;) If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to CreateObject 'ADODB.Connection'.&quot; Else oADOConn.Provider = &quot;ADSDsOObject&quot; oADOConn.Open &quot;ADs Provider&quot; If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to initialize the 'ADSDSOObject'.&quot; Else Set oRootDSE = GetObject(&quot;LDAP://RootDSE&quot;) ' Create a forest instance Dim oForestInstance, strForestDNSRoot strForestDNSRoot = Mid(oRootDSE.Get(&quot;rootDomainNamingContext&quot;), 4) strForestDNSRoot = Replace(strForestDNSRoot, &quot;,DC=&quot;, &quot;.&quot;) Set oForestInstance = oForestsCollection.CreateInstance oForestInstance.AddKeyProperty &quot;ForestName&quot;, strForestDNSRoot oForestsCollection.AddInstance oForestInstance Dim rsMonitor, rsSites, strQuery strQuery = &quot;;(objectCategory=site);cn,adspath,distinguishedName;subtree&quot; Set rsSites = oADOConn.Execute(strQuery) if Err.number <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;The query '&quot; & strQuery & &quot;' failed to execute.&quot; Else While Not rsSites.EOF Err.Clear 'create site instance Dim oSiteInstance Set oSiteInstance = oSitesCollection.CreateInstance oSiteInstance.AddKeyProperty &quot;SiteName&quot;, rsSites.fields(&quot;cn&quot;) oSitesCollection.AddInstance oSiteInstance

' Create a collection to hold the relationships between this site and it's servers Dim oSiteToDCCollection Set oSiteToDCCollection = oDiscData.CreateRelationshipCollection oSiteToDCCollection.TypeID = &quot;Site-DC&quot; oSiteToDCCollection.SourceScopeFilter.AddKeyProperty &quot;SiteName&quot;, rsSites.Fields(&quot;cn&quot;)

' Create a collection to hold the site to computer relationships Dim oSitetoComputerCollection Set oSitetoComputerCollection = oDiscData.CreateRelationshipCollection oSitetoComputerCollection.TypeID = &quot;Site-Computer&quot; oSitetoComputerCollection.SourceScopeFilter.AddKeyProperty &quot;SiteName&quot;, rsSites.Fields(&quot;cn&quot;) ' Create a collection to hold the site to bridgehead relationships Dim oSitetoBridgeheadCollection Set oSitetoBridgeheadCollection = oDiscData.CreateRelationshipCollection oSitetoBridgeheadCollection.TypeID = &quot;Site-Bridgehead&quot; oSitetoBridgeheadCollection.SourceScopeFilter.AddKeyProperty &quot;SiteName&quot;, rsSites.Fields(&quot;cn&quot;) oSitetoBridgeheadCollection.AddScopeProperty &quot;TransportType&quot;

Err.Clear

' For each site, enumerate it's servers strQuery = &quot;<&quot; & rsSites.Fields(&quot;adspath&quot;) & &quot;>;(objectCategory=nTDSDSA);adspath;subtree&quot; Dim rsServers Set rsServers = oADOConn.Execute(strQuery) If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;The query '&quot; & strQuery & &quot;' failed to execute.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else While Not rsServers.EOF ' From the ntdsasettings object, get it's parent which is the server object ' This should always work, but we don't really care if it does or not, we'll               ' pick up any failure after attempting to get its parent. Dim oNTDSASettings Set oNTDSASettings = GetObject(rsServers.Fields(&quot;adspath&quot;)) Err.Clear Dim oServer Set oServer = GetObject(oNTDSASettings.Parent) If Err.Number = 0 Then ' Determine the flat domain name for the DC                 Dim strFlatDomain strFlatDomain = oOOMADs.GetFlatDomainForDC(oServer.Get(&quot;dnsHostName&quot;)) 'relate site to computer Dim oSiteToComputerInstance Set oSiteToComputerInstance = oSitetoComputerCollection.CreateInstance oSiteToComputerInstance.TargetProperty.AddKeyProperty &quot;ComputerName&quot;, strFlatDomain & &quot;\&quot; & oServer.Get(&quot;CN&quot;) oSitetoComputerCollection.AddInstance oSiteToComputerInstance 'relate site to computer Dim oSiteToDCInstance Set oSiteToDCInstance = oSiteToDCCollection.CreateInstance oSiteToDCInstance.TargetProperty.AddKeyProperty &quot;ComputerName&quot;, strFlatDomain & &quot;\&quot; & oServer.Get(&quot;CN&quot;) oSiteToDCInstance.TargetProperty.AddKeyProperty &quot;DC Name&quot;, oServer.Get(&quot;CN&quot;) oSiteToDCCollection.AddInstance oSiteToDCInstance 'Relationship &quot;Computer&quot; is a member of &quot;Group&quot; Dim oGroupToComputerInstance Set oGroupToComputerInstance = oGroupToComputerCollection.CreateInstance oGroupToComputerInstance.TargetProperty.AddKeyProperty &quot;ComputerName&quot;, strFlatDomain & &quot;\&quot; & oServer.Get(&quot;CN&quot;) oGroupToComputerCollection.AddInstance oGroupToComputerInstance ' If the server is a preferred bridgehead server for the site, ' create a 'site-bridgehead' relationship and set the transport ' type on the relationship. Dim arrBridgeheadTransports arrBridgeheadTransports = oServer.GetEx(&quot;bridgeheadTransportList&quot;) If IsArray(arrBridgeheadTransports) Then Dim strTransportType For Each strTransportType in arrBridgeheadTransports Dim oSiteToBridgeheadInstance Set oSiteToBridgeheadInstance = oSitetoBridgeheadCollection.CreateInstance oSiteToBridgeheadInstance.TargetProperty.AddKeyProperty &quot;ComputerName&quot;, strFlatDomain & &quot;\&quot; & oServer.Get(&quot;CN&quot;) oSiteToBridgeheadInstance.AddProperty &quot;TransportType&quot;, Mid(strTransportType, 4, Instr(strTransportType, &quot;,&quot;) - 4) oSitetoBridgeheadCollection.AddInstance oSiteToBridgeheadInstance Next End If                 If IsGC(oNTDSASettings) Then Dim oGCInstance Set oGCInstance = oGCCollection.CreateInstance oGCInstance.SourceProperty.AddKeyProperty &quot;ComputerName&quot;, strFlatDomain & &quot;\&quot; & oServer.Get(&quot;CN&quot;) oGCInstance.TargetProperty.AddKeyProperty &quot;GC Name&quot;, strFlatDomain & &quot;\&quot; & oServer.Get(&quot;CN&quot;) oGCCollection.AddInstance oGCInstance End If               End If                rsServers.MoveNext Wend End If           Err.Clear ' Find all the subnets for the site Dim rsSubnets strQuery = &quot;;(&(objectCategory=subnet)(siteObject=&quot; & rsSites.Fields(&quot;distinguishedName&quot;) & &quot;));cn;subtree&quot; Set rsSubnets = oADOConn.Execute(strQuery) If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;The query '&quot; & strQuery & &quot;' failed to execute.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) oSiteInstance.AddProperty &quot;Subnets&quot;, &quot;&quot; Else Dim strSubnets, iSubnetCount iSubnetCount = 0 strSubnets = &quot;&quot; '              ' Only list 5 subnets, if we listed them all, we'd run out of              ' space in the attribute. '             While Not rsSubnets.EOF AND iSubnetCount <= 5 iSubnetCount = iSubnetCount + 1 If iSubnetCount <= 5 Then strSubnets = strSubnets & vbCrLf & rsSubnets.Fields(&quot;cn&quot;) Else strSubnets = strSubnets & vbCrLf & &quot;...&quot; End If               rsSubnets.MoveNext Wend oSiteInstance.AddProperty &quot;Subnets&quot;, strSubnets End If           Err.Clear ' Find the ISTG for the site. Dim rsSiteSettings strQuery = &quot;<&quot; & rsSites.Fields(&quot;adspath&quot;) & &quot;>;(interSiteTopologyGenerator=*);interSiteTopologyGenerator,options;subtree&quot; Set rsSiteSettings = oADOConn.Execute(strQuery) If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;The query '&quot; & strQuery & &quot;' failed to execute.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else If Not rsSiteSettings.EOF Then If rsSiteSettings.Fields(&quot;options&quot;) AND 1 THEN oSiteInstance.AddProperty &quot;ISTG Enabled&quot;, &quot;No&quot; oSiteInstance.AddProperty &quot;ISTG Role Holder&quot;, &quot;None&quot; Else oSiteInstance.AddProperty &quot;ISTG Enabled&quot;, &quot;Yes&quot; Dim oISTG Set oISTG = GetObject(&quot;LDAP://&quot; & rsSiteSettings.Fields(&quot;interSiteTopologyGenerator&quot;) ) If Err <> 0 Then oSiteInstance.AddProperty &quot;ISTG Role Holder&quot;, &quot;Unknown&quot; Else Dim oISTGServer Set oISTGServer = GetObject(oISTG.Parent) oSiteInstance.AddProperty &quot;ISTG Role Holder&quot;, oISTGServer.Get(&quot;CN&quot;) End If               End If              Else oSiteInstance.AddProperty &quot;ISTG Role Holder&quot;, &quot;None&quot; oSiteInstance.AddProperty &quot;ISTG Enabled&quot;, &quot;Unknown&quot; End If           End If            ' Add the site to bridgehead relationship collection to the discover data oDiscData.AddCollection oSitetoBridgeheadCollection ' Add the site to computer relationship collection to the discover data oDiscData.AddCollection oSitetoComputerCollection

' Add the site to DC relationship collection to the discover data oDiscData.AddCollection oSiteToDCCollection

rsSites.MoveNext Wend

End If       Err.Clear

Dim rsSiteLinks strQuery = &quot;;(objectCategory=siteLink);cn,cost,siteList,replInterval,adspath,schedule,isDeleted;subtree&quot; Set rsSiteLinks = oADOConn.Execute(strQuery) if Err.number <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;The query '&quot; & strQuery & &quot;' failed to execute.&quot; Else While NOT rsSiteLinks.EOF Dim oTransport, strTransport Dim bDeleted bDeleted = rsSiteLinks.Fields(&quot;isDeleted&quot;) If Err <> 0 Then oError.Init(Err) On Error Goto 0 Dim strSiteLinkPath strSiteLinkPath = rsSiteLinks.Fields(&quot;adspath&quot;) oError.Raise &quot;Failed to determine if object '&quot; & strSiteLinkPath & &quot;' is deleted.&quot; Else If IsNull(bDeleted) Or bDeleted = False Then Set oTransport = GetObject(rsSiteLinks.Fields(&quot;adspath&quot;)) If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to get object '&quot; & rsSiteLinks.Fields(&quot;adspath&quot;) & &quot;'.&quot; strTransport = &quot;Unknown&quot; Err.Clear Else Set oTransport = GetObject(oTransport.Parent) strTransport = oTransport.Get(&quot;cn&quot;) End If               Dim oSiteLinkInstance Set oSiteLinkInstance = oSiteLinkCollection.CreateInstance oSiteLinkInstance.AddKeyProperty &quot;Site Link Name&quot;, rsSiteLinks.Fields(&quot;cn&quot;) oSiteLinkInstance.AddProperty &quot;Replicates Every&quot;, rsSiteLinks.Fields(&quot;replInterval&quot;) oSiteLinkInstance.AddProperty &quot;Transport&quot;, strTransport oSiteLinkInstance.AddProperty &quot;Cost&quot;, rsSiteLinks.Fields(&quot;cost&quot;) oSiteLinkCollection.AddInstance oSiteLinkInstance

' create relationship collection for site link to site Dim oSiteLinkToSiteCollection Set oSiteLinkToSiteCollection = oDiscData.CreateRelationshipCollection oSiteLinkToSiteCollection.TypeID= &quot;Site-AD Site Link&quot; oSiteLinkToSiteCollection.TargetScopeFilter.AddKeyProperty &quot;Site Link Name&quot;, rsSiteLinks.Fields(&quot;cn&quot;) oDiscData.AddCollection oSiteLinkToSiteCollection If IsArray(rsSiteLinks.Fields(&quot;siteList&quot;)) Then Dim arrSites, strSite, strSite2 arrSites = rsSiteLinks.Fields(&quot;siteList&quot;) Dim i, j                 For i = LBound(arrSites) To UBound(arrSites) strSite = arrSites(i) Dim oSiteLinkToSiteInstance Set oSiteLinkToSiteInstance = oSiteLinkToSiteCollection.CreateInstance oSiteLinkToSiteInstance.SourceProperty.AddKeyProperty &quot;SiteName&quot;, Mid(strSite, 4, Instr(strSite, &quot;,&quot;) - 4) oSiteLinkToSiteCollection.AddInstance oSiteLinkToSiteInstance Next End If             End If            End If            rsSiteLinks.MoveNext Wend if Err.number <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to discovery topology correctly.&quot; End If       End If        Err.Clear Dim rsNamingContexts strQuery = &quot;;(&(objectCategory=crossRef)(!(|(cn=Enterprise Schema)(cn=Enterprise Configuration))));ncName,dnsRoot;subtree&quot; Set rsNamingContexts = oADOConn.Execute(strQuery) If Err.number <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;The query '&quot; & strQuery & &quot;' failed to execute.&quot; Else ' Create a collection to hold all the naming contexts Dim oNCCollection Set oNCCollection = oDiscData.CreateCollection oNCCollection.ClassID = &quot;Naming Context&quot; oNCCollection.AddScopeProperty &quot;DNSRoot&quot; oNCCollection.AddScopeProperty &quot;ApplicationPartition&quot; oDiscData.AddCollection oNCCollection While Not rsNamingContexts.EOF Dim oNCInstance Set oNCInstance = oNCCollection.CreateInstance oNCInstance.AddKeyProperty &quot;NCName&quot;, rsNamingContexts.Fields(&quot;ncName&quot;) Dim arrDNSRoots arrDNSRoots = rsNamingContexts.Fields(&quot;DNSRoot&quot;).Value If IsArray(arrDNSRoots) Then oNCInstance.AddProperty &quot;DNSRoot&quot;, arrDNSRoots(0) End If           Dim bIsNDNC bIsNDNC = False ' Bind to the object to attempt to get the msDS-NC-Replica-Locations attribute. ' W2K doesn't support this attribute, so if we ask for it in the query, an error ' would be raised in W2K forests. Dim oNamingContext Set oNamingContext = GetObject(rsNamingContexts.Fields(&quot;adspath&quot;)) If IsObject(oNamingContext) Then If IsNull(oNamingContext.Get(&quot;msDS-NC-Replica-Locations&quot;)) Then oNCInstance.AddProperty &quot;ApplicationPartition&quot;, &quot;False&quot; Else oNCInstance.AddProperty &quot;ApplicationPartition&quot;, &quot;True&quot; bIsNDNC = True End If           End If            oNCCollection.AddInstance oNCInstance ' Find the FSMO role holders for each NC           If IsArray(arrDNSRoots) Then oOOMADs.Domain = arrDNSRoots(0) Dim strMaster

Err.Clear ' NDNCs don't have a RID master or PDC so don't try to discover them If Not(bIsNDNC) Then Dim oMasterCollection Set oMasterCollection = oDiscData.CreateRelationshipCollection oMasterCollection.TypeID = &quot;RID-NamingContext&quot; oMasterCollection.TargetScopeFilter.AddKeyProperty &quot;NCName&quot;, rsNamingContexts.Fields(&quot;ncName&quot;) strMaster = oOOMADS.RIDMaster If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;Failed to get the RID Master for the domain '&quot; & _ arrDNSRoots(0) & &quot;'.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else AddSourceInstanceToCollection oMasterCollection, strMaster End If               oDiscData.AddCollection oMasterCollection Err.Clear

Set oMasterCollection = oDiscData.CreateRelationshipCollection oMasterCollection.TypeID = &quot;PDC-NamingContext&quot; oMasterCollection.TargetScopeFilter.AddKeyProperty &quot;NCName&quot;, rsNamingContexts.Fields(&quot;ncName&quot;) strMaster = oOOMADS.PDCMaster If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;Failed to get the PDC Master for the domain '&quot; & _ arrDNSRoots(0) & &quot;'.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else AddSourceInstanceToCollection oMasterCollection, strMaster End If               oDiscData.AddCollection oMasterCollection End If             Err.Clear Set oMasterCollection = oDiscData.CreateRelationshipCollection oMasterCollection.TypeID = &quot;Infrastructure-NamingContext&quot; oMasterCollection.TargetScopeFilter.AddKeyProperty &quot;NCName&quot;, rsNamingContexts.Fields(&quot;ncName&quot;) strMaster = GetInfrastructureMasterUsingWellKnownGUID(arrDNSRoots(0), rsNamingContexts.Fields(&quot;ncName&quot;).Value) If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;Failed to get the Infrastructure Master for the domain '&quot; & _ arrDNSRoots(0) & &quot;'.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else AddSourceInstanceToCollection oMasterCollection, strMaster End If             oDiscData.AddCollection oMasterCollection End If

rsNamingContexts.MoveNext Wend End If     End If

oOOMADs.Domain = &quot;&quot; Err.Clear ' Create the schema master and domain naming master instances Set oMasterCollection = oDiscData.CreateRelationshipCollection oMasterCollection.TypeID = &quot;Computer-DomainNamingMaster&quot; strMaster = oOOMADS.DomainNamingMaster If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;Failed to get the Domain Naming Master.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else AddComputerRelationshipToCollection oMasterCollection, strMaster, &quot;DomainNamingMasterName&quot; oDiscData.AddCollection oMasterCollection End If     Set oMasterCollection = oDiscData.CreateRelationshipCollection oMasterCollection.TypeID = &quot;Computer-SchemaMaster&quot; strMaster = oOOMADS.SchemaMaster If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;Failed to get the Schema Master.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else AddComputerRelationshipToCollection oMasterCollection, strMaster, &quot;SchemaMasterName&quot; oDiscData.AddCollection oMasterCollection End If   End If    ScriptContext.Submit oDiscData If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to submit discovery data.&quot; End If

ScriptContext.Echo &quot;AD Discovery took &quot; & DateDiff(&quot;s&quot;, dtStart, Now) & &quot; seconds to complete&quot; End Sub

'****************************************************************************** Sub AddSourceInstanceToCollection(oCollection, strSource) ' ' Purpose:     Creates an instance of a relationship and set's the computer '              name to that of the source, and adds it to the collection. ' ' Parameters:  oCollection - the collection to add the instance to '               strSource - the source to add to the collection ' ' Return:      None ' On Error Resume Next Dim strFlatDomainName, strFlatComputerName strFlatDomainName = GetFlatDomainForDC(strSource) If Err = 0 Then strFlatComputerName = oOOMADs.GetFlatComputerName(strSource) End If If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;Failed to get the flat names for the computer '&quot; & strSource & &quot;'.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else Dim oInstance Set oInstance = oCollection.CreateInstance oInstance.SourceProperty.AddKeyProperty &quot;ComputerName&quot;, strFlatDomainName & &quot;\&quot; & strFlatComputerName oCollection.AddInstance oInstance End If           End Sub

'****************************************************************************** Sub AddComputerRelationshipToCollection(oCollection, strInstance, strTargetKeyName) ' ' Purpose:     Creates an instance of a computer relationship and set's the '              computer name as the source of the relationship and the '              target name to the target of the relationship ' ' Parameters:  oCollection - the collection to add the instance to '               strInstance - the instance to add to the collection '              strTargetKeyName - the name of the key value on the target ' ' Return:      None ' On Error Resume Next Dim strFlatDomainName, strFlatComputerName strFlatDomainName = GetFlatDomainForDC(strInstance) If Err = 0 Then strFlatComputerName = oOOMADs.GetFlatComputerName(strInstance) End If If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;Failed to get the flat names for the computer '&quot; & strInstance & &quot;'.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else Dim oRelationship Set oRelationship = oCollection.CreateInstance oRelationship.SourceProperty.AddKeyProperty &quot;ComputerName&quot;, strFlatDomainName & &quot;\&quot; & strFlatComputerName oRelationship.TargetProperty.AddKeyProperty strTargetKeyName, strFlatDomainName & &quot;\&quot; & strFlatComputerName oCollection.AddInstance oRelationship End If           End Sub

'****************************************************************************** Function IsGC(oNTDSASettings) ' ' Purpose:     Determines whether the NTDSASettings object passed in belongs '              to a GC ' ' Parameters:  oNTDSASettings - the object to check ' ' Return:      Bool, True if it is a GC, False otherwise ' On Error Resume Next IsGC = False ' Check whether the DC is a GC Dim rsGCs, strGUID, strQuery ' Reformat the GUID so it's the right format for what we want to do strGUID = ReformatGUID(oNTDSASettings.GUID)

strQuery = &quot;>;(&(objectCategory=nTDSDSA)(options:1.2.840.113556.1.4.803:=1));adspath,cn;base&quot; Set rsGCs = oADOConn.Execute(strQuery) If Err <> 0 Then CreateEvent EVENT_ID_TOPOLOGY_DISCOVERY_FAILURE, _ EVENT_TYPE_WARNING, _ &quot;The query '&quot; & strQuery & &quot;' failed to execute.&quot; & vbCrLf & _ &quot;This will cause an incomplete topology to be displayed.&quot; & vbCrLf & _ &quot;The error returned was:&quot; & _ vbCrLf & GetErrorString(Err) Else If Not rsGCs.EOF Then ' It is a GC     IsGC = True End If End If End Function

'****************************************************************************** Function ReformatGUID(strOrigGUID) ' ' Purpose:     Reformats an obj.GUID into a format that's useful in queries. ' ' Parameters:  strOrigGUID - the original format of the GUID ' ' Return:      String, the reformatted GUID ' If Len(strOrigGUID) <> 32 Then Err.Raise &H80070057, SCRIPT_NAME & &quot;::ReformatGUID&quot;, &quot;Invalid Argument&quot; End If ReformatGUID = Mid(strOrigGUID, 7, 2) & Mid(strOrigGUID, 5, 2) & Mid(strOrigGUID, 3, 2) & Mid(strOrigGUID, 1, 2) ReformatGUID = ReformatGUID & &quot;-&quot; ReformatGUID = ReformatGUID & Mid(strOrigGUID, 11, 2) & Mid(strOrigGUID, 9, 2) ReformatGUID = ReformatGUID & &quot;-&quot; ReformatGUID = ReformatGUID & Mid(strOrigGUID, 15, 2) & Mid(strOrigGUID, 13, 2) ReformatGUID = ReformatGUID & &quot;-&quot; ReformatGUID = ReformatGUID & Mid(strOrigGUID, 17, 4) ReformatGUID = ReformatGUID & &quot;-&quot; ReformatGUID = ReformatGUID & Mid(strOrigGUID, 21, 12) End Function

'****************************************************************************** Sub CreateEvent(lngEventID, lngEventType, strMessage) ' ' Purpose:     Creates a MOM event ' ' Parameters:  lngEventID, the ID for the event '              lngEventType, the severity for the event. See constants at head of file '              strMessage, the message for the event ' ' Return:      nothing ' On Error Resume Next

Dim objNewEvent

' Create a new event Set objNewEvent = ScriptContext.CreateEvent

' Set event properties objNewEvent.Message = strMessage objNewEvent.EventNumber = lngEventID objNewEvent.EventType = lngEventType

' Submit the event ScriptContext.Submit objNewEvent

Set objNewEvent = Nothing End Sub

'****************************************************************************** Function GetErrorString(oErr) ' ' Purpose:     Attempts to find the description for an error if an error with '              no description is passed in. ' ' Parameters:  oErr, the error object ' ' Return:      String, the description for the error. (Includes the error code.) ' Dim lErr, strErr lErr = oErr strErr = oErr.Description

On Error Resume Next If 0 >= Len(strErr) Then ' If we don't have an error description, then check to see if the error ' is a 0x8007xxxx error. If it is, then look it up. Const ErrorMask = &HFFFF0000 Const HiWord8007 = &H80070000 Const LoWordMask = 65535         ' This is equivalent to 0x0000FFFF

If (lErr And ErrorMask) = HiWord8007 Then ' Attempt to use 'net helpmsg' to get a description for the error. Dim oShell Set oShell = CreateObject(&quot;WScript.Shell&quot;) If Err = 0 Then Dim oExec Set oExec = oShell.Exec(&quot;net helpmsg &quot; & (lErr And LoWordMask))

Dim strMessage, i       Do          strMessage = oExec.stdout.ReadLine i = i + 1 Loop While (Len(strMessage) = 0) And (i < 5)

strErr = strMessage End If   End If    End If

GetErrorString = vbCrLf & &quot;The error returned was: '&quot; & strErr & &quot;' (0x&quot; & Hex(lErr) & &quot;)&quot; End Function

'****************************************************************************** Function GetUTCOffset ' ' Purpose:     To get the difference between UTC and local time ' ' Arguments:   None ' ' Returns:   The number of hours between UTC and local time ' Dim oSet, oOS, lTZOffset Set oSet = GetObject(&quot;winmgmts:&quot;).InstancesOf(&quot;Win32_OperatingSystem&quot;)

For Each oOS In oSet lTZOffset = oOS.CurrentTimeZone Next

' Convert from number of minutes to number of hours GetUTCOffset = lTZOffset / 60 End Function

'****************************************************************************** Function GetInfrastructureMasterUsingWellKnownGUID(strDNSHost, strNCDN) ' ' Purpose:     Finds (if available) the infrastructure role master in the naming '            context identified by strRoot. ' ' Arguments:   strNCDN, the DN of the naming context to look in ' ' Returns:   Object, either the ADSI object representing the infrastructure '              role master or NULL ' ' Remarks:   Any error encountered will cause the method to throw an '             exception. This must be handled by the caller. '            This method does 3 binds. In a slow system this may take '            some time. ' On Error Resume Next Dim oContainer, oNTDS, oMaster, lErr, strErr, strSource, strLDAPSearchComputer strLDAPSearchComputer = &quot;LDAP://&quot; & strDNSHost & &quot;/&quot; Set oContainer = GetObject(strLDAPSearchComputer & &quot;&quot;) If Err <> 0 Then lErr = Err.number strErr = &quot;Failed to bind to '&quot; & strLDAPSearchComputer & _ &quot;'.&quot; & GetErrorString(Err) On Error Goto 0 Err.Raise lErr, &quot;GetInfrastructureMasterUsingWellKnownGUID&quot;, strErr End If Set oNTDS = GetObject(strLDAPSearchComputer & oContainer.Get(&quot;fSMORoleOwner&quot;)) If Err <> 0 Then lErr = Err.number strErr = &quot;Failed to get the 'fSMORoleOwner' attribute from the object '&quot; & _ strLDAPSearchComputer & &quot;'.&quot; & GetErrorString(Err) On Error Goto 0 Err.Raise lErr, &quot;GetInfrastructureMasterUsingWellKnownGUID&quot;, strErr End If Set oMaster = GetObject(oNTDS.Parent) If Err <> 0 Then lErr = Err.number strErr = &quot;Failed to get the object '&quot; & oNTDS.Parent & &quot;'.&quot; & GetErrorString(Err) On Error Goto 0 Err.Raise lErr, &quot;GetInfrastructureMasterUsingWellKnownGUID&quot;, strErr End If GetInfrastructureMasterUsingWellKnownGUID = oMaster.Get(&quot;dnsHostName&quot;) If Err <> 0 Then lErr = Err.number strErr = &quot;Failed to get the dnsHostName attribute of '&quot; & oNTDS.Parent & &quot;'.&quot; & GetErrorString(Err) On Error Goto 0 Err.Raise lErr, &quot;GetInfrastructureMasterUsingWellKnownGUID&quot;, strErr End If End Function

'****************************************************************************** Function GetFlatDomainForDC(strDNSHostName) ' ' Purpose:   To obtain the flat (netbios) domain name for a DC ' ' Arguments: strDNSHostName - the DCs DNS name ' ' Returns:   String, the flat domain name ' On Error Resume Next ' Search for the Server object with the DNSHostName = strDNSHostName ' Use it's ServerReference to work out what domain it's in. ' Get the domain partition object. ' If the Netbios attribute is filled in, get that, otherwise use ' the top level DNS name. Dim strQuery strQuery = &quot;;(&(objectCategory=Server)(dnsHostName=&quot; & strDNSHostName & &quot;));serverReference,distinguishedName;subtree&quot; If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to construct the query to find the Server '&quot; & strDNSHostName & &quot;'.&quot; End If

Dim rsServers Set rsServers = oADOConn.Execute(strQuery) If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to execute the query to find the Server '&quot; & strDNSHostName & &quot;'.&quot; End If Do Until rsServers.EOF or Len(GetFlatDomainForDC) > 0 Dim strDomainDN, strServerRef, iStartDomain strServerRef = rsServers.Fields(&quot;ServerReference&quot;) If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to get the ServerReference attribute of '&quot; & strDNSHostName & &quot;'.&quot; End If   iStartDomain = Instr(strServerRef, &quot;DC=&quot;) If iStartDomain > 0 Then strDomainDN = Mid(strServerRef, iStartDomain) strQuery = &quot;;(&(objectCategory=crossRef)(ncName=&quot; & strDomainDN & &quot;));netbiosName,dnsRoot;subtree&quot; If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to construct the query to find the Domain '&quot; & strDomainDN & &quot;'.&quot; End If

Dim rsDomains Set rsDomains = oADOConn.Execute(strQuery) If Err <> 0 Then oError.Init(Err) On Error Goto 0 oError.Raise &quot;Failed to execute the query to find the Domain '&quot; & strDomainDN & &quot;'.&quot; End If     Do Until rsDomains.EOF or Len(GetFlatDomainForDC) > 0 Dim strFlatName strFlatName = rsDomains.Fields(&quot;netbiosName&quot;) If Err <> 0 Or Len(strFlatName) = 0 Then Dim arrDNSRoots arrDNSRoots = rsDomains.Fields(&quot;dnsRoot&quot;) If IsArray(arrDNSRoots) Then strFlatName = arrDNSRoots(0) ElseIf IsString(arrDNSRoots) Then strFlatName = arrDNSRoots End If         Dim iEndTopLevel iEndTopLevel = Instr(strFlatName, &quot;.&quot;) If iEndTopLevel > 0 Then strFlatName = Left(strFlatName, iEndTopLevel -1) End If       End If        GetFlatDomainForDC = strFlatName rsDomains.MoveNext Loop End If   rsServers.MoveNext Loop If Len(GetFlatDomainForDC) = 0 Then On Error Goto 0 Err.Raise E_INVALIDARG, SCRIPT_NAME & &quot;::GetFlatDomainForDC&quot;, &quot;Failed to obtain the flat domain name for '&quot; & strDNSHostName & &quot;'.&quot; End If End Function

Script installation information
To install this script, follow these steps:
 * 1) Start the MOM 2005 Administrator console.
 * 2) Expand Microsoft Operations Manager , expand Management Packs, expand Rule Groups, expand Microsoft Windows Active Directory, expand Replication Topology Discovery (Site Links), and then click Event Rules.
 * 3) Open the Script - AD Topology Discovery script.
 * 4) Click the Responses tab.
 * 5) In the Response list, click Script - AD Topology Discovery, and then click Edit.
 * 6) In the Launch a Script dialog box, click Edit.
 * 7) Click the Script tab.
 * 8) Copy the contents of the script into a text file as a backup copy of the original script, and then delete the contents of the Specify the JScript source code for the script box.
 * 9) Paste the contents of the ADTopologyScriptNew.txt file into the Specify the JScript source code for the script box.
 * 10) Click OK three times to exit all the open dialog boxes.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Keywords: kbtshoot kbprb KB901051

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.