Directory Service (Ds) Functions

The Directory Service (DS) functions provide a mechanism for locating a domain controller (DC) in a Windows NT domain. The architecture interacts with clients as well as servers in all versions of Windows NT.The following functions allow developers to work with the domain controller in the directory service:

Function Description
DsGetDcName Returns the name of a domain controller (DC) in a specified domain. The DsGetDcName function provides information from the DOMAIN_CONTROLLER_INFO structure.
DsGetSiteName Returns the name of the site for either the domain controller, member workstation, or the member server.
DsValidateSubnetName Validates a subnet name of a valid IP address.

The DC locator (DsGetDcName) is implemented by the Netlogon service. Each DC registers its DNS name on the DNS server and its Netbios name using a transport-specific mechanism (for example, in WINS). The DC locator looks up the name, then sends a datagram to (or "pings") the DC that registered the name. For Netbios domain names, the datagram is a mailslot message. For DNS domain names, the datagram is an LDAP UDP search. Each such DC responds indicating that it is currently operational. The first DC to respond is returned to the caller.

The returned DC is cached so that subsequent callers need not repeat the precedingalgorithm, and to encourage all callers to use that same DC. This ensures that a single client has a consistent view of the contents of the DC.

When searching for a DC by DNS domain name, the DC locator will attempt to find a DC in the "closest" site. Each DC registers additional DNS records indicating what site that the DC is in and what sites the DC includes. The DC locator first searches for this site-specific DNS record before searching for the DNS record that is not site-specific (thus preferring a DC in that site). When the DC locator sends a datagram to the DC, the DC looks up the IP address of the client in the Configuration/Sites/Subnet container of the DS to find a subnet object. The SiteObject property of the subnet object defines the name of the site that contains the client. The DC responds to the ping with the name of the site that contains the client, along with an indicator of whether this DC covers that site. If the DC does not include that site and the DC locator has not yet attempted to find a DC in that site, the DC locator tries again to find a DC in the site.

To find the name of the site containing the client,use the DsGetSiteName function. The names of the objects in the Configuration/Sites/Subnet container must be valid subnet names. The DsValidateSubnetName function indicates whether a specified subnet name is valid.