I'm having difficulty setting up my authentication with active directory.
I have a LDAP server at ldap://server-1
and the domain is "DC=company,DC=com"
Following this answer, I tried to setup the scheme like:
using(PrincipalContext pc = new PrincipalContext(ContextType.Domain, "ldap://server-1", "DC=company,DC=com"))
{
// validate the credentials
bool isValid = pc.ValidateCredentials("myuser", "mypassword");
}
But I keep getting error The server could not be contacted / The LDAP server is unavailable
. I've tried lots of variations of using the server name and the domain but I don't know much about the LDAP protocol, so don't know if I'm setting things up right.
I know the LDAP is available because I get results from cmd line dsquery DC=company,DC=com
- type queries.