大网数据广告活动
服务器运维问答

Finding PDC from domain name in Linux (Linux equivalent of nltest /dcname:MYDOMAIN)

· 52CE 我爱测

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 …

问题原文

原帖链接 · 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).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-10-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。