使用 Java 进行“nslookup -type=srv”
Java 有没有办法对 SRV 记录进行 Nslookup 搜索?
我需要绑定到 Active Directory,并希望使用 SRV 记录来帮助确定集群中的哪些 AD 处于活动状态。
在命令行中,nslookup 搜索字符串为: 'nslookup -type=srv _ ldap._tcp.ActiveDirectory 域名'
谢谢。
Is there a way in Java to do a Nslookup search on SRV records?
I need to bind to Active Directory and would like to use the SRV records to help determine which of the ADs in the cluster are live.
In command line the nslookup search string is: 'nslookup -type=srv _ ldap._tcp.ActiveDirectory domain name'
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如埃里克森指出的,JNDI API 有一个 使用 JNDI 的 DNS 提供商,您可以在该链接上阅读有关内容。有关查询
_ldap._.tcp.mydomain.com
记录的工作示例,请参阅 此代码来自 Hudson。我相信,在使用 DNS 提供程序之前,您需要使用以下内容加载它(根据上面的 Hudson 代码修改):
从那里您可以通过以下方式获取 SRV 记录:
我已经成功地使用了这样的代码在几个非常直接的 AD 集成项目中。
As erickson pointed out, the JNDI API has a provider for DNS using JNDI, which you can read up about on that link. For a working sample query the
_ldap._.tcp.mydomain.com
record, see this code from Hudson.I believe that before utilizing the DNS provider, you need to load it with something like this (modified from the Hudson code above):
from there you, can obtain the SRV record via something like:
I've successfully managed to use code like this in a couple of projects for very straight-forward AD integration.
我从未使用过它,但我相信 Java 的 用于命名服务的“JNDI”API 有一个 DNS 提供商。将域名作为
DirContext
查找,然后检查其“SRV”属性。就像我说的,我还没有尝试过这个,但我希望它可以帮助你开始。
I've never used it, but I believe that Java's "JNDI" API for naming services has a provider for DNS. Look up the domain name as a
DirContext
, and then examine its "SRV" attributes.Like I say, I haven't experimented with this, but I hope it helps you get started.
我使用 http://www.dnsjava.org/ 它完成了这项工作
I used http://www.dnsjava.org/ and it did the job