G
GuruPrashanth
Guest
Hi All
I am able to validate user credentials using Principal Context when connecting with default context option as shown below.
PrincipalContext context = new PrincipalContext(ContextType.Domain, "ldaps.lab.com");
bool authenticated= context.ValidateCredentials("administrator", "administrator");
But when I connect using SSL context option as shown in below code it throws "The server cannot be contated". I have verified the connectivity to 636 port using ldp and LDAP browser.
PrincipalContext context = new PrincipalContext(ContextType.Domain, "ldaps.lab.com", "DC=com,DC=lab", ContextOptions.SecureSocketLayer|ContextOptions.Negotiate);
bool authenticated= context.ValidateCredentials("administrator", "administrator");
I observed the below error in the event viewer
'The certificate received from the remote server was issued by an untrusted certificate authority. Because of this, none of the data contained in the certificate can be validated. The SSL connection request has failed. The attached data contains the server certificate.'
When I tried using LDAPConnection class as shown below, it works fine. Is there a way to do SSL connection using PrincipalContext?
LdapConnection ldapConnection = new LdapConnection("ldaps.lab.com:636");
var networkCredential = new NetworkCredential("administrator", "administrator", "lab");
ldapConnection.SessionOptions.SecureSocketLayer = true;
ldapConnection.SessionOptions.VerifyServerCertificate += delegate { return true; };
ldapConnection.AuthType = AuthType.Negotiate;
ldapConnection.Bind(networkCredential);
Continue reading...
I am able to validate user credentials using Principal Context when connecting with default context option as shown below.
PrincipalContext context = new PrincipalContext(ContextType.Domain, "ldaps.lab.com");
bool authenticated= context.ValidateCredentials("administrator", "administrator");
But when I connect using SSL context option as shown in below code it throws "The server cannot be contated". I have verified the connectivity to 636 port using ldp and LDAP browser.
PrincipalContext context = new PrincipalContext(ContextType.Domain, "ldaps.lab.com", "DC=com,DC=lab", ContextOptions.SecureSocketLayer|ContextOptions.Negotiate);
bool authenticated= context.ValidateCredentials("administrator", "administrator");
I observed the below error in the event viewer
'The certificate received from the remote server was issued by an untrusted certificate authority. Because of this, none of the data contained in the certificate can be validated. The SSL connection request has failed. The attached data contains the server certificate.'
When I tried using LDAPConnection class as shown below, it works fine. Is there a way to do SSL connection using PrincipalContext?
LdapConnection ldapConnection = new LdapConnection("ldaps.lab.com:636");
var networkCredential = new NetworkCredential("administrator", "administrator", "lab");
ldapConnection.SessionOptions.SecureSocketLayer = true;
ldapConnection.SessionOptions.VerifyServerCertificate += delegate { return true; };
ldapConnection.AuthType = AuthType.Negotiate;
ldapConnection.Bind(networkCredential);
Continue reading...