0
votes

We have a situation with Active Directory during project startup:

Environment Information: Central server that has the Main Active Directory server : Windows server 2012 R2 64-bit, IP Address: 192.168.1.10

Office server that has a read only Active Directory server: Windows server 2012 R2 64-bit, IP Address: 192.168.50.10 (this Active directory replicates users & workstations information from the central server). The two server are connected via a DSL network.

Our C# application runs on the office network and the Operator PC (Windows 7 64-bit) is joined to the domain in the office. it has to authenticate users from Active Directory in the Office Server using the following code.

 using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "mydomain.com"))
                    {
                        // validate the credentials
                        bool isValid = pc.ValidateCredentials("username", "password");
                        Log("Create principal context done");
                    }

The problem is we have the following errors that appear almost every time we try to run this code:

  1. The server is not operational
  2. The server could not be contacted
  3. The LDAP server is unavailable

In case this code works it take about 1 minutes to finish. Note: this code never fail in our development environment (LAN network with the same IP range 10.0.0.).

Any suggestions?

1
Is it possible that PrincipalContext is selecting a domain which is not on or possibly a domain in a different site that it is not routable? Do you have your Sites-and-Services configured correctly with your networks? You could try to using the PrincipalContext(ContextType, String, String) constructor and pass it the specific DC you want to connect to and see if the problem goes away. - Sam

1 Answers

-1
votes

Do you have any firewall or DNS issues?

Are you sure you are calling the correct server?