Note that there are some explanatory texts on larger screens.

plurals
  1. POConsistently receive PrincipalServerDownException when calling ValidateCredentials() method
    text
    copied!<p>I am trying to authenticate AD users in a .net 4.0 application using the new(ish) System.DirectoryServices.AccountManagement namespace. I'm currently testing using standard LDAP, although my plan is to switch to LDAPS once I resolve this issue.</p> <p>My application is running on a webserver that is not part of the target AD domain, nor is it trusted. I <em>do</em> have a network route to the AD server, and have a valid service account that I can use to query it. Necessary ports are open as well (389 for LDAP, 636 for LDAPS). I can sucessfully bind to and query the AD server from the webserver using LDAPExplorerTool 2 and the paths/credentials I indicate below (<a href="http://ldaptool.sourceforge.net/" rel="nofollow">http://ldaptool.sourceforge.net/</a>).</p> <p>In the below code, I always receive a PrincipalServerDownException (The server could not be contacted) when attempting to create the context. Try/catch block and other necessities are currently being omitted for testing purposes.</p> <p><pre><code> string server = "adServer.mydomain.com:389"; // Properly resolves to IP of AD server string path = "dc=mydomain,dc=com"; string serviceUser = "username"; // Username in SAM format - no prefix/suffix string servicePassword = "password"; string username = "loginuser"; // Username in SAM format - no prefix/suffix string password = "password";</p> <p>using (PrincipalContext context = new PrincipalContext(ContextType.Domain, server, path, ContextOptions.Negotiate, serviceUser, servicePassword)) { return context.ValidateCredentials(username, password, ContextOptions.Negotiate); } </pre></code></p> <hr> <h2>Update</h2> <p>I attempted to authenticate using the LDAPExplorer tool and the code above while my network manager captured the traffic using wireshark. He determined that no packets were received from the webserver's source IP when the code ran.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload