Performing DNS "ANY" Lookup using Java JNDI -


i using java jndi perform dns lookups using following basic syntax per sscce below, trying query records using "any" attribute:

import java.util.*; import javax.naming.*; import javax.naming.directory.*;  public class sscce {   public static void main(string[] args) {     try {       properties p = new properties();       p.put(context.initial_context_factory, "com.sun.jndi.dns.dnscontextfactory");       initialdircontext idc = new initialdircontext(p);        attributes attrs = idc.getattributes("netnix.org", new string[] { "* *" });       attribute attr = attrs.get("* *");        if (attr != null) {         (int = 0; < attr.size(); i++) {           system.out.println("found " + (string)attr.get(i));         }       }       else {         system.out.println("found nothing");       }     }     catch (exception e) {       e.printstacktrace();     }   } } 

my question around being able query resource type of "any" should return dns resource records associated specific domain - example below using "host" utility.

chrixm@puffy(:):~$ host -t netnix.org netnix.org has spf record "v=spf1 include:_spf.google.com ~all" netnix.org mail handled 10 aspmx2.googlemail.com. netnix.org mail handled 5 alt1.aspmx.l.google.com. netnix.org mail handled 1 aspmx.l.google.com. netnix.org mail handled 5 alt2.aspmx.l.google.com. netnix.org mail handled 10 aspmx3.googlemail.com. netnix.org name server ns-1154.awsdns-16.org. netnix.org name server ns-941.awsdns-53.net. netnix.org name server ns-61.awsdns-07.com. netnix.org name server ns-1880.awsdns-43.co.uk. 

i have read http://docs.oracle.com/javase/7/docs/technotes/guides/jndi/jndi-dns.html, says:

superclass attribute identifiers defined. these may useful when querying records using dircontext.getattributes() method. if attribute name has "*" in place of type name (or class name), represents records of type (or class). example, attribute identifier "in *" may passed getattributes() method find internet class records. attribute identifier "* *" represents records of class or type.

however, java jndi doesn't understand resource record of "*" or "* *" above code doesn't return records (i able query "ns" or "soa", etc individually) - has had experience of getting working. can of course query each individual resource type, considering there valid record type of "any" per rfc 1035 (type id 255) seems inefficient?

after examining methods of attributes class noticed getall() method. after further searching able implement following allows search using "*" record type , print records.

attributes attrs = idc.getattributes("netnix.org", new string[] { "*" }); namingenumeration<?> ae = attrs.getall();  while (ae.hasmore()) {   attribute attr = (attribute)ae.next();   (int = 0; < attr.size(); i++) {     object = attr.get(i);     if (a instanceof string) {       system.out.println(attr.getid() + " " + a);     }     else {       system.out.println(attr.getid() + " not ascii");     }   } } ae.close(); 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -