Can I use Golang to get the internal domain name of an Active Directory environment?

只愿长相守 提交于 2019-12-20 03:23:39

问题


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:


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.



来源:https://stackoverflow.com/questions/43279703/can-i-use-golang-to-get-the-internal-domain-name-of-an-active-directory-environm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!