问题原文
原帖链接 · LFLFM · CC BY-SA 4.0
I can find the PDC (Primary Domain Controller) from my Windows machine using the command nltest /dcname:MYDOMAIN.
I need to find the PCD from a Linux machine. Is there a way?
The only information that my script will have is the domain name and user name.
background of this (for the curious/completeness): I'm automating some password management procedures and so far I can deal with all the ftp, ssh and database passwords. Now I've managed to maintain the AD users as well, but I've had to supply the PDC's myself after looking them up from my windows machine - I'd like to supply just the domain and let my scripts do the rest, including the PDC lookup.
The given answer by Lenniey is perfect and resolved my problem; just as a complete reference, I looked further into this and found the following sites that can be useful for others with similar needs:
DNS Records that are required for proper functionality of Active Directory
Find domain name with command line
已采纳解答
原帖链接 · Lenniey · CC BY-SA 4.0
You can use
nslookup -q=SRV _ldap._tcp.pdc._msdcs.domain.tld and then use awk to format your output, e.g.:
nslookup -q=SRV _ldap._tcp.pdc._msdcs.domain.tld | grep _ldap | awk '{print $7}'
(it isn't pretty, but you can refine it to your use-case).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
