Reputation: 153
We have following server details:
Server: CN=HQITSA01,OU=Domain Controllers,DC=example,DC=net
We don't have username and password.
Our Code:
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, "example.net");
We have tried above code to connect but it throwing error: The server could not be contacted.
Upvotes: 0
Views: 462
Reputation: 3321
The right instruction should be:
var context = new PrincipalContext(ContextType.Domain, "EXAMPLE", "DC=EXAMPLE,DC=net");
where EXAMPLE here is the NETBIOS name for the domain. You can also try with
var context = new PrincipalContext(ContextType.Domain, null);
to connect to the current domain, if example.net is you current domain.
Check the documentation of PrincipalContext
object at this link for further details or this SO question.
BTW, "the server could not be contacted" looks like a simple connectivity problem.
Upvotes: 1