public class ActiveDirectoryDnsLocator extends Object
_msdcs
subdomain is ignored. The
server selection algorithm for failover is fully implemented.
Here is a minimal example how to create a ActiveDirectoryDnsLocator
with the supplied
builder:
ActiveDirectoryDnsLocator.Builder builder = new ActiveDirectoryDnsLocator.Builder(); ActiveDirectoryDnsLocator locator = builder.build(); HostPort[] servers = locator.locate("ldap", "ad.example.com");An
ActiveDirectoryDnsLocator
object will be initially preconfigured by its builder for
you:
com.sun.jndi.dns.DnsContextFactory
.DirContext
properties can be found
here.
Make sure that you pass reasonable/valid values only otherwise the behavior is undefined.
Note: This class uses JULI to print log messages, enable at least level FINE
to see output.
Modifier and Type | Class and Description |
---|---|
static class |
ActiveDirectoryDnsLocator.Builder
A builder to construct an
ActiveDirectoryDnsLocator with a fluent interface. |
static class |
ActiveDirectoryDnsLocator.HostPort
A mere container for a host along with a port.
|
Modifier and Type | Method and Description |
---|---|
ActiveDirectoryDnsLocator.HostPort[] |
locate(String service,
String domainName)
Locates a desired service via DNS within an Active Directory domain, sorted and selected
according to RFC 2782.
|
ActiveDirectoryDnsLocator.HostPort[] |
locate(String service,
String site,
String domainName)
Locates a desired service via DNS within an Active Directory site and domain, sorted and
selected according to RFC 2782.
|
public ActiveDirectoryDnsLocator.HostPort[] locate(String service, String site, String domainName) throws NamingException
service
- the service to be locatedsite
- the Active Directory site the client resides indomainName
- the desired domain name. Can be any naming context name.NullPointerException
- if service or domain name is nullIllegalArgumentException
- if service or domain name is emptyNamingException
- if an error has occurred while creating or querying the DNS directory contextIllegalStateException
- if any of the DNS returned RRs not adhere to the RFCpublic ActiveDirectoryDnsLocator.HostPort[] locate(String service, String domainName) throws NamingException
service
- the service to be locateddomainName
- the desired domain name. Can be any naming context name.NullPointerException
- if service or domain name is nullIllegalArgumentException
- if service or domain name is emptyNamingException
- if an error has occurred while creating or querying the DNS directory contextIllegalStateException
- if any of the DNS returned RRs not adhere to the RFCCopyright © 2016–2021 Michael Osipov. All rights reserved.