0

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.

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.