如何通過編程方式使用C#
獲取域控制器IP地址?如何獲取域控制器IP地址
2
A
回答
3
感謝所有,
我做了本規範再次
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.DirectoryServices.AccountManagement;
using System.DirectoryServices.ActiveDirectory;
public doIt()
{
DirectoryContext mycontext = new DirectoryContext(DirectoryContextType.Domain,"project.local");
DomainController dc = DomainController.FindOne(mycontext);
IPAddress DCIPAdress = IPAddress.Parse(dc.IPAddress);
}
感謝
1
那麼這裏是如何爲在MS網站描述得到它的一般工作流程:
http://support.microsoft.com/kb/247811
這裏是PInvoke.net鏈接調用引用DsGetDcName將功能:
http://pinvoke.net/default.aspx/netapi32/DsGetDcName.html
你可以下去,髒,如在第一個鏈接描述做原料DNS A記錄的查詢,但我認爲卡爾的PInvoke我應該做的伎倆。
希望幫助,
邁克
+0
還沒有在C#中嘗試過,但在Java中它是真實的容易去的DNS記錄路由。 – 2009-01-29 17:33:43
5
這是我會怎麼做。
您需要使用System.Net和System.DirectoryServices。
// get root of the directory data tree on a directory server
DirectoryEntry dirEntry = new DirectoryEntry("LDAP://rootDSE");
// get the hostname of the directory server of your root (I'm assuming that's what you want)
string dnsHostname = dirEntry.Properties["dnsHostname"].Value.ToString();
IPAddress[] ipAddresses = Dns.GetHostAddresses(dnsHostname);
相關問題
- 1. 如何從IP地址獲取域名
- 2. 如何在Grails控制器中獲取客戶端IP地址?
- 3. 如何獲取Symfony2控制器中的用戶IP地址?
- 4. 如何在Symfony2控制器中獲取外部IP地址?
- 5. 如何獲取IP地址?
- 6. 如何獲取IP地址?
- 7. 如何獲取服務器IP地址?
- 8. 如何在C++中使用域名獲取域名IP地址?
- 9. C#:從域名獲取IP地址?
- 10. 從IP地址中獲取域名
- 11. 如何使用koaJS獲取本地域IP地址
- 12. 獲取IP地址
- 13. 獲取IP地址
- 14. 獲取IP地址
- 15. 如何在MVC 4控制器中獲取客戶端IP地址?
- 16. 如何獲取IP地址何時瀏覽域名?
- 17. 獲取本地IP地址
- 18. 如何從IP地址列表中獲取域名
- 19. 如何獲取局域網中的IP地址列表?
- 20. 如何在局域網中獲取外部IP地址?
- 21. Unix - 如何獲取域名的IP地址?
- 22. 如何使用jsp頁面獲取局域網IP地址?
- 23. 通過背景工作控制在局域網上獲取IP地址
- 24. 如何獲取node.js中的IP地址
- 25. 如何在PageMethod中獲取IP地址?
- 26. 如何使用R獲取IP地址?
- 27. 如何僅獲取IP地址/子網
- 28. 如何獲取內部IP地址?
- 29. 如何獲取IP地址[MYSQL]
- 30. 如何獲取後端的IP地址?
要檢索跨不同的域,你需要做:`new DirectoryContext(DirectoryContextType.Domain,「project.local」,「validUserInDomain」,「validUserPassword」); – 2012-11-13 14:45:54