Showing posts with label Active Directory Sites and Services. Show all posts
Showing posts with label Active Directory Sites and Services. Show all posts

Thursday, December 4, 2008

Retrieving the Site Name for the Local Computer

Reports the site name for the local computer.

Set objADSysInfo = CreateObject("ADSystemInfo")
WScript.Echo "Current site name: " & objADSysInfo.SiteName

This is a VB Script, this can be used by saving the file in .vbs file

Retrieving the Domain Controller Site Name

Reports the site name for a specified domain controller (or computer).

strDcName = "atl-dc-01"
Set objADSysInfo = CreateObject("ADSystemInfo")
strDcSiteName = objADSysInfo.GetDCSiteName(strDcName)
WScript.Echo "DC Site Name: " & strDcSiteName

This is a VB Script, this can be used by saving the file in .vbs file

Renaming an Active Directory Site

Renames an Active Directory site.

strOldSiteRDN = "cn=Default-First-Site-Name"
strNewSiteRDN = "cn=Ga-Atl-Sales"
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strSitesContainer = "LDAP://cn=Sites," & strConfigurationNC
strOldSitePath = "LDAP://" & strOldSiteRDN & ",cn=Sites," & strConfigurationNC
 
Set objSitesContainer = GetObject(strSitesContainer)
objSitesContainer.MoveHere strOldSitePath, strNewSiteRDN

This is a VB Script, this can be used by saving the file in .vbs file

Listing the Subnets in an Active Directory Site

Lists subnets in a specified Active Directory site

 

strSiteRDN = "cn=Ga-Atl-Sales"
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strSitePath = "LDAP://" & strSiteRDN & ",cn=Sites," & strConfigurationNC
 
Set objSite = GetObject(strSitePath)
 
objSite.GetInfoEx Array("siteObjectBL"), 0
arrSiteObjectBL = objSite.GetEx("siteObjectBL")
 
WScript.Echo strSiteRDN & " Subnets" & vbCrLf & _
    String(Len(strSiteRDN) + 8, "-")
 
For Each strSiteObjectBL In arrSiteObjectBL
    WScript.Echo Split(Split(strSiteObjectBL, ",")(0), "=")(1)
Next

This is a VB Script, this can be used by saving the file in .vbs file

Listing the Subnets in all Active Directory Sites

Lists subnets in all Active Directory sites. STDOUT is formatted as a comma-separated values file to accommodate redirecting to a file format compatible with Excel.

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," & strConfigurationNC
 
Set objSubnetsContainer = GetObject(strSubnetsContainer)
 
objSubnetsContainer.Filter = Array("subnet")
 
Set objHash = CreateObject("Scripting.Dictionary")
 
For Each objSubnet In objSubnetsContainer
    objSubnet.GetInfoEx Array("siteObject"), 0
    strSiteObjectDN = objSubnet.Get("siteObject")
    strSiteObjectName = Split(Split(strSiteObjectDN, ",")(0), "=")(1)
 
    If objHash.Exists(strSiteObjectName) Then
        objHash(strSiteObjectName) = objHash(strSiteObjectName) & "," & _
            Split(objSubnet.Name, "=")(1)
    Else
        objHash.Add strSiteObjectName, Split(objSubnet.Name, "=")(1)
    End If
Next
 
For Each strKey In objHash.Keys
    WScript.Echo strKey & "," & objHash(strKey)
Next

This is a VB Script, this can be used by saving the file in .vbs file

Listing Servers in an Active Directory Site

Lists servers in a specified Active Directory site.

strSiteRDN = "cn=Ga-Atl-Sales"
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strServersPath = "LDAP://cn=Servers," & strSiteRDN & ",cn=Sites," & _
    strConfigurationNC
 
Set objServersContainer = GetObject(strServersPath)
 
For Each objServer In objServersContainer
    WScript.Echo objServer.Name
Next

This is a VB Script, this can be used by saving the file in .vbs file

Listing Active Directory Sites

Lists Active Directory sites.

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strSitesContainer = "LDAP://cn=Sites," & strConfigurationNC
Set objSitesContainer = GetObject(strSitesContainer)
 
objSitesContainer.Filter = Array("site")
 
For Each objSite In objSitesContainer
    WScript.Echo objSite.Name
Next

This is a VB Script, this can be used by saving the file in .vbs file

Listing Active Directory Connections

Lists Active Directory connections (nTDSConnection objects) for a specified domain controller.

strDcRDN   = "cn=atl-dc-01"
strSiteRDN = "cn=Ga-Atl-Sales"
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strNtdsSettingsPath = "LDAP://cn=NTDS Settings," & strDcRDN & _
    ",cn=Servers," & strSiteRDN & ",cn=Sites," & strConfigurationNC
 
Set objNtdsSettings = GetObject(strNtdsSettingsPath)
 
objNtdsSettings.Filter = Array("nTDSConnection")
 
WScript.Echo strDcRDN & " NTDS Connection Objects" & vbCrLf & _
    String(Len(strDcRDN) + 24, "=")
 
For Each objConnection In objNtdsSettings
    WScript.Echo "Name:      " & objConnection.Name
    WScript.Echo "Enabled:   " & objConnection.enabledConnection
    WScript.Echo "From:      " & Split(objConnection.fromServer, ",")(1)
    WScript.Echo "Options:   " & objConnection.Options
    WScript.Echo "Transport: " & Split(objConnection.transportType, ",")(0)
    WScript.Echo "Naming Contexts"
    WScript.Echo "---------------"
    For Each objDNWithBin In objConnection.GetEx("ms-DS-ReplicatesNCReason")
        Wscript.Echo objDNWithBin.DNString
    Next
    WScript.Echo
Next

This is a VB Script, this can be used by saving the file in .vbs file

Determining the Protocols Over Which a Bridgehead Server Replicates

Reads the bridgeheadTransportList from a domain controller in a site.

On Error Resume Next
   
Set objServer = GetObject _
    ("LDAP://CN=SEA-DC-01,CN=Servers,CN=Default-First-Site-Name,"  & _
        " CN=Sites,CN=Configuration,DC=fabrikam,DC=com")
 
dnBHTList = objServer.GetEx("bridgeheadTransportList")
 
WScript.Echo "Bridge Head Transport List:"
WScript.Echo "This multi-valued attribute lists the protocol" & _
    "transports over which this BridgeHead Server replicates"
For Each dnValue in dnBHTList
    WScript.Echo dnValue
Next

This is a VB Script, this can be used by saving the file in .vbs file

Deleting an Active Directory Subnet

Deletes an Active Directory subnet.

strSubnetCN = "cn=192.168.1.0/26"
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," & strConfigurationNC
 
Set objSubnetsContainer = GetObject(strSubnetsContainer)
objSubnetsContainer.Delete "subnet", strSubnetCN

This is a VB Script, this can be used by saving the file in .vbs file

Creating an Active Directory Subnet

Creates an Active Directory subnet.

strSubnetRDN     = "cn=192.168.1.0/26"
strSiteObjectRDN = "cn=Ga-Atl-Sales"
strDescription   = "192.168.1.0/255.255.255.192"
strLocation      = "USA/GA/Atlanta"
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strSiteObjectDN = strSiteObjectRDN & ",cn=Sites," & strConfigurationNC
 
strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," & strConfigurationNC
 
Set objSubnetsContainer = GetObject(strSubnetsContainer)
 
Set objSubnet = objSubnetsContainer.Create("subnet", strSubnetRDN)
objSubnet.Put "siteObject",  strSiteObjectDN
objSubnet.Put "description", strDescription
objSubnet.Put "location",    strLocation
objSubnet.SetInfo

This is a VB Script, this can be used by saving the file in .vbs file

Creating an Active Directory Site Link

Creates an Active Directory site link

strSite1Name    = "Ga-Atl-Sales"
strSite2Name    = "Wa-Red-Sales"
strSiteLinkRDN  = "cn=[" & strSite1Name & "][" & strSite2Name & "]"
intCost         = 100
intReplInterval = 60
strDescription  = "[" & strSite1Name & "][" & strSite2Name & "]"
 
Const ADS_PROPERTY_UPDATE = 2
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
 
strSite1DN = "cn=" & strSite1Name & ",cn=Sites," & strConfigurationNC
strSite2DN = "cn=" & strSite2Name & ",cn=Sites," & strConfigurationNC
 
Set objInterSiteTransports = GetObject("LDAP://" & _
    "cn=IP,cn=Inter-Site Transports,cn=Sites," & strConfigurationNC)
 
Set objSiteLink = objInterSiteTransports.Create("siteLink", strSiteLinkRDN)
objSiteLink.Put "cost",         intCost
objSiteLink.Put "replInterval", intReplInterval
objSiteLink.Put "description",  strDescription
 
objSiteLink.PutEx ADS_PROPERTY_UPDATE, "siteList", _
                  Array(strSite1DN, strSite2DN)
objSiteLink.SetInfo

This is a VB Script, this can be used by saving the file in .vbs file

Creating an Active Directory Site

Creates an Active Directory site and sets the site link for the new site.

strSiteRDN      = "cn=Ga-Atl-Sales"
strSiteLinkRDN  = "cn=DEFAULTIPSITELINK"
strSiteLinkType = "IP"                      ' Valid values: "IP" or "SMTP"
 
Const ADS_PROPERTY_APPEND = 3
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
strSitesContainer = "LDAP://cn=Sites," & strConfigurationNC
 
Set objSitesContainer = GetObject(strSitesContainer)
 
Set objSite = objSitesContainer.Create("site", strSiteRDN)
objSite.SetInfo
 
Set objLicensingSiteSettings = objSite.Create("licensingSiteSettings", _
    "cn=Licensing Site Settings")
objLicensingSiteSettings.SetInfo
 
Set objNtdsSiteSettings = objSite.Create("nTDSSiteSettings", _
     "cn=NTDS Site Settings")
objNtdsSiteSettings.SetInfo
 
Set objServersContainer = objSite.Create("serversContainer", "cn=Servers")
objServersContainer.SetInfo
 
strSiteLinkPath = "LDAP://" & strSiteLinkRDN & ",cn=" & strSiteLinkType & _
    ",cn=Inter-Site Transports,cn=Sites," & strConfigurationNC
 
Set objSiteLink = GetObject(strSiteLinkPath)
objSiteLink.PutEx ADS_PROPERTY_APPEND, "siteList", _
                  Array(objSite.Get("distinguishedName"))
objSiteLink.SetInfo

This is a VB Script, this can be used by saving the file in .vbs file

Troubleshooting 'There are no more endpoints available from the endpoint mapper errors'

1. Run the Directory Services MPSReports on the problem domain controllers to gather data.

2. Collect information on network hardware (routers, switches, firewalls) that separate partner domain controllers.

3. Verify the following ports are open on any network hardware separating the domain controllers:

389 TCP (LDAP) or TCP 686 if using Secure Sockets Layer (SSL).
389 UDP (LDAP ping).
88 TCP/UDP (Kerberos).
53 TCP/UDP (DNS).
445 TCP/UDP (SMB over IP traffic).

  • Verify RPC ports, for more information see KB articles 224196, 154596, and 319553.
  • Portqry can be used to test if these ports are open. For more information see KB article 310456.

4. Follow the steps listed in KB article 159211 to test for black hole router issues. These may occur when a network router receives a packet larger than the Maximum Transfer Unit (MTU) of the next network segment, and that packet's IP layer "don't fragment" bit is flagged, the router should send an Internet Control Message Protocol (ICMP) destination unreachable message back to the sending host. When this does not happen, packets can be dropped, causing a variety of errors that will vary with the application that is communicating over the failed link.

5. Check for Kerberos fragmentation. To do this, type ping <destination computer> -f -l 1500. Start with 1500 first, working up to 2000. If it fails before 2000, then packets are probably being fragmented. For more information see KB article 244474.

Troubleshooting 'RPC Server is unavailable errors'

It is important to understand the internal name resolution configuration of the environment. Verify which servers are authoritative for the zone and how the client is configured to retrieve the DNS records. In most cases, the client should only point to DNS servers that can resolve the internal domain name.

1. Verifying proper client configuration

  • Check local DNS settings under the TCP/IP settings of the network adapter. For more information on verifying TCP/IP settings, see Knowledge Base (KB) article 308199.
  • In most cases, the client should not be pointing to an Internet service provider (ISP) for either their Preferred or Alternate DNS server. ISPs commonly do not register the service resource records (SRV) records that are required to locate a domain controller. For more information see KB article 261968.
  • Clients should only point to internal DNS servers that can resolve the internal domain, and the internal DNS server should resolve names on the Internet for the clients, which is often done by configuring forwarders on the internal DNS server.

2. Verifying proper DNS server configuration

  • In an Active Directory domain, typically a DNS server in a child domain should forward to a DNS server in the parent or root domain. For more information, see KB article 300202.
  • As an alternative to forwarding from child to parent, the child DNS server may be configured with a secondary zone for the parent domain. For more information see KB article 313563.
  • Microsoft® Windows Server™ 2003 can be configured to forward queries for a specific domain to specific DNS servers (conditional forwarding), and allow normal name resolution for all other domains if desired. In the DNS management tool, right-click the name of the DNS server in the left pane, select Properties, select the Forwarders tab, and then add the domain name under DNS domain, typing the IP addresses of the servers under Selected domain’s forwarder IP list. For more information see article 304491.
  • Check for improperly configured forwarders.
    1. If a forwarder that the domain name system (DNS) server is using is unable to resolve records for the zone, query it directly using a tool such as Nslookup to verify that the forwarder itself is the problem. For more information see KB article 200525.
    2. Verify the DNS server is not configured to forward to non-recursive DNS server. This can be verified by viewing the response from the forwarder in a network trace and checking the DNS Flags field.

3. Verifying proper zone delegation

  • Ensure the child zone is properly delegated from the parent. There should be a name server (NS) record in the parent domain for the child domain. The exception is if both child and parent domains are part of the same zone on the same DNS server. For more information see KB article 255248.
  • Make sure the zone has not been delegated to a DNS server that is not authoritative for that zone. For more information see the section on delegation in KB article 255248.

4. Verifying configuration of internal root servers

  • Windows 2000 has some definite steps that need to be followed besides just modifying the Cache.dns file on the DNS server. For more information see KB article 249868.

5. Verifying proper registration of DNS records

  • After verifying settings in client and zone configuration sections, delete the Netlogon.dns and Netlogon.dnb files on the domain controller and restart the Net Logon service. For more information see KB article 259277.
  • Verify that the domain controller does not have a disjointed namespace. For more information see KB article 257623.
  • Verify Net Logon dynamic updates are not disabled in the registry by checking that the UseDynamicDNS value in the registry key below is not set to 0.
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters
  • If SRV records are properly registering, and Net Logon A records are not, verify the RegisterDnsARecords value in the registry key below is not set to 0.
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters
  • If a domain controller is not registering a globally unique identifier (GUID),  Net Logon event 5774 referencing the SRV record. Check for an MX (Mail Exchange) wildcard entry. For more information see KB article 325208. Also see KB article 259277 for additional information on Event ID 5774, 5775 and 5781.
  • Verify domain controllers that are replication partners in the domain have their GUID registered in the forest root zone.
    Example of domain GUID record:
    Name: e99e82d5-deed-11d2-b15c-00c04f5cb503._msdcs.contoso.com
    Type:  CNAME
    Data:  dc01.contoso.com
    Records for global catalog servers are registered in the forest root domain, regardless of whether the domain controller is in a child domain or a different tree of the forest. The forest root domain is the first domain created in the forest.
    Domain controllers attempting to replicate will initiate a query to Active Directory for their configured replication partner and GUID. They then initiate a DNS query for the CNAME record for the GUID, similar to the record in the example above. If the GUID is not present in the DNS zone, the domain controller will not replicate with that partner.
  • Each domain controller must also have a host record registered for their name (CNAME) in the DNS zone.
  • Verify that both domain controllers involved in the replication can resolve the above DNS records for each other.
  • If there are replication problems in the forest root zone, verify that domain controllers are not pointing to themselves for DNS. As a rule, only one domain controller in the forest root domain should be pointed to itself for either Preferred or Alternate DNS server in their TCP/IP properties setting. All other domain controllers should be pointed to DNS servers other than themselves. For more information see KB article 275278.