For example if I have the following SRV record defined in my DNS config
_dev._tcp IN SRV 0 0 8400 dev.server.com.
I can execute the following command
host -lt SRV server.com
And it gives me complete list of SRV records in the dns server(server.com). If I want to do the same thing using JNDI lookup
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
DirContext ctx = new InitialDirContext(env);
Attributes attributes = ctx.getAttributes("server.com", new String [] { "SRV" });
return attributes;
The above code is not returning any attributes. If I change the penultimate line in the above code to this,
Attributes attributes = ctx.getAttributes("_dev._tcp.server.com", new String [] { "SRV" });
it works.
But the problem is I don't know the complete domain name in prior and I have to lookup the SRV record to find the complete domain name.
Any ideas as how to do this?