英文:
Can I use Golang to get the internal domain name of an Active Directory environment?
问题
我想使用Golang获取我所在的内部Windows域的FQDN。例如,如果名称是CORP.com,我想要一个用Golang编写的小脚本来为我找到这个FQDN。
这个可能吗?
英文:
I want to use Golang to get the FQDN of the internal Windows domain I am on. If the name was CORP.com, for example, I want a small script in Golang to find this for me.
Is this possible?
答案1
得分: 1
使用Go的标准库没有内置的方法,但是,你可能可以通过使用DNS查找短主机名(以获取DNS已知的IP),然后通过DNS进行反向查找该IP(这应该会给你机器的完全限定域名FQDN),其中的结尾(减去短主机名)应该是你的AD域。大部分这个逻辑已经在go-fqdn中实现了。
英文:
There's no built-in way using Go's stdlib, however, you might be able to do it by looking up the short hostname by DNS (to get the IP known by DNS), then doing a reverse lookup of that IP by DNS (which should give you the machine's FQDN), the end of which (minus the short hostname) should be your AD domain. Most of this logic is implemented in go-fqdn.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论