SRV 描述:
static String getDefaultLdapHost() { try { Hashtable<String, String> env = new Hashtable(); env.put( "java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory" ); DirContext dns = new InitialDirContext( env ); InetAddress address = InetAddress.getLocalHost(); String domain = address.getCanonicalHostName(); if( domain.equals( address.getHostAddress() ) ) { //domain is a ip address domain = getDnsPtr( dns ); } int idx = domain.indexOf( '.' ); if( idx < 0 ) { //computer is not in a domain? We will look in the DNS self. domain &