title: Why can't the Active Directory server be contacted via PrincipalContext?
body: <p>I am facing some problems in accessing Active Directory from my WinForm app. What I want is to create a user and query user from Active Directory.</p>
  
  <p>Here is code snippet for find user:</p>
  
  <pre><code>public bool FindUser(string username)
  {
      using (PrincipalContext context = new PrincipalContext(
          ContextType.Domain, 
          this.domainName, 
          this.DomainUserName, 
          this.DomainPassword))
      {                
          UserPrincipal user = UserPrincipal.FindByIdentity(context, username);
          return (user != null) ? true : false;
      }
  }
  </code></pre>
  
  <p>i am unable to create object of <code>PrincipalContext</code> based on given arguments. I am getting this exception:</p>
  
  <pre><code>Exception: The server could not be contacted.
  </code></pre>
  
  <p>and inner exception states that,</p>
  
  <pre><code>Inner Exception: The LDAP server is unavailable.
  </code></pre>
  
  <p>where as domain is running. I can ping to it and can also connect to this domain.</p>