有人可以稍微详细解释一下,为什么以下代码有效:
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain,"some.domain.com", "username","password"))
但是当我尝试将任何其他内容传递给构造函数时,例如IP地址和端口,我会收到错误?
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain,"123.45.56.78:910", "username","password"))
以上几行不起作用,但我希望能够从外面的计算机访问AD,如果它有有效的凭据,我该怎么做,以及为什么一个例子可以工作,而另一个没有?
答案 0 :(得分:0)
You are close, you are are just missing LDAP://
at the beginning of your IP address.
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain,"LDAP://123.45.56.78:910", "username","password"))
LDAP is a protocol that allows you to communicate with your Active Directory domain.