我可以使用Golang获取Active Directory环境的内部域名吗?

huangapple go评论104阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2017年4月7日 21:41:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/43279703.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定