如何连接到同首席上下文的Active Directory? [英] How to connect to Active Directory with Principal Context?
问题描述
我已经在这一段时间,我总是得到:
I've been at this for a while and I'm always getting:
System.DirectoryServices.AccountManagement.PrincipalServerDownException
System.DirectoryServices.AccountManagement.PrincipalServerDownException
我想这意味着我的连接设置(连接字符串)是错误的。
Which I think means my connection setup(connection string) is wrong.
当我写DSQUERY服务器在计算机上CMD那里的Active Directory是我得到:
When I write "dsquery server" on cmd on the computer where the Active Directory is I get:
CN = DCESTAGIO,CN =服务器,CN =默认 - 站点 - 名,CN = CN的站点=配置,DC = estagioit,DC =本地
"CN=DCESTAGIO,CN=SERVERS,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=estagioit,DC=local"
我试着用以下方法以下连接:
I've tried the following connecting in the following ways:
1
PrincipalContext thisPrincipalContext = new PrincipalContext(ContextType.Domain, "192.168.56.101", "DC=estagioit,DC=local");
2
2:
PrincipalContext thisPrincipalContext = new PrincipalContext(ContextType.Domain, "192.168.56.101/DC=estagioit,DC=local");
3
3:
PrincipalContext thisPrincipalContext = new PrincipalContext(ContextType.Domain, "192.168.56.101/CN=DCESTAGIO,DC=estagioit,DC=local");
4
4:
PrincipalContext thisPrincipalContext = new PrincipalContext(ContextType.Domain, "192.168.56.101/CN=DCESTAGIO,CN=SERVERS,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=estagioit,DC=local");
5:
5:
PrincipalContext thisPrincipalContext = new PrincipalContext(ContextType.Domain, "LDAP://192.168.56.101/CN=Users,DC=estagioit,DC=local");
和其他一些方法...
And some other ways...
什么是错的,我怎么能做出这方面的工作任何想法
Any ideas on what's wrong and how I can make this connection work?
PS:该IP是正确看作是我用它来ping它的工作
PS: The ip is correct seen as I've used it to ping and it's working.
PSS:我真的,真的需要这个工作尽快如果你有一切他们都欢迎任何建议。
PSS: I really, really need this working ASAP if you have any suggestions at all they're all welcome.
推荐答案
如果你看一下在 PrincipalContext
构造函数的文档,它应该是很清楚的:
If you look at the documentation for the PrincipalContext
constructors, it should be quite clear:
public PrincipalContext(ContextType contextType, string name)
或
public PrincipalContext(ContextType contextType, string name, string container)
所以你基本上需要:
- 您的上下文类型(此处为:
ContextType.Domain
) - 域名(尝试只是Netbios的名称,如YOURDOMAIN - 或者离开为NULL默认域)
- 可选的容器(作为LDAP路径 - 一个尊贵的名字,完整的路径,但没有任何
LDAP://
前缀)
- your context type (here:
ContextType.Domain
) - the domain name (try just the "Netbios" name, e.g. "YOURDOMAIN" - or leave NULL for "default" domain)
- optionally a container (as an LDAP path - a "distinguished" name, full path but without any
LDAP://
prefix)
因此,尝试这样的:
PrincipalContext thisPrincipalContext =
new PrincipalContext(ContextType.Domain, "ESTAGIOIT");
或
PrincipalContext thisPrincipalContext =
new PrincipalContext(ContextType.Domain, null); // default domain
或
PrincipalContext thisPrincipalContext =
new PrincipalContext(ContextType.Domain, "ESTAGIOIT", "DC=estagioit,DC=local");
或
PrincipalContext thisPrincipalContext =
new PrincipalContext(ContextType.Domain, null, "CN=Users,DC=estagioit,DC=local");
这篇关于如何连接到同首席上下文的Active Directory?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!