[Windows] 透過 Domain Controller 取得 LDAP

如題,在大公司使用AD驗證是很常見的,且當有多個子公司時,LDAP就有可能會更換,此時突然變動就沒法登入了,確實有點麻煩,解決方式如下。

//	假設你的 DC如下
//	DC = "dc=DC01,dc=yourdomain,dc=intra";
	
//	於 CMD 輸入以下指令
nltest /dsgetdc:DC01.yourdomain.intra
  
//	結果會如下:
DC: \\DC01.yourdomain.intra
Address: \\10.1.1.10
Dom Guid: ...
Dom Name: yourdomain.intra
Forest Name: yourdomain.intra
Flags: ...

//	而 Address 就是LDAP,Port通常為389。
//	C#程式就會如下...
DC = "dc=DC01,dc=yourdomain,dc=intra";
LDAP = "LDAP://10.1.1.10:389";
  

留言

這個網誌中的熱門文章

[C#] 無法載入檔案或組件 或其相依性的其中之一。 找到的組件資訊清單定義與組件參考不符。 (發生例外狀況於 HRESULT: 0x80131040)

[Cloud CICD] 後端篇 - .Net8 WebApi, Github Action, Azure App Service

[Cloud CICD] 前端篇 - Vue3, Github Action, Azure Static Web App