public static String[] getNSNames(String name) throws NamingException {
Attributes dnsLookup = context.getAttributes(name, new String[] {
- "NS"
+ "NS"
});
return extractTextEntries(dnsLookup.get("NS"));
}
env.put(Context.AUTHORITATIVE, "true");
env.put(Context.PROVIDER_URL, "dns://" + server);
InitialDirContext context = new InitialDirContext(env);
+ try {
- Attributes dnsLookup = context.getAttributes(name, new String[] {
- "TXT"
- });
+ Attributes dnsLookup = context.getAttributes(name, new String[] {
+ "TXT"
+ });
+ return extractTextEntries(dnsLookup.get("TXT"));
+ } finally {
+ context.close();
+ }
- return extractTextEntries(dnsLookup.get("TXT"));
}
private static String[] extractTextEntries(Attribute nsRecords) throws NamingException {
public static String[] getMXEntries(String domain) throws NamingException {
Attributes dnsLookup = context.getAttributes(domain, new String[] {
- "MX"
+ "MX"
});
return extractTextEntries(dnsLookup.get("MX"));
}