Pregunta

Estoy tratando de conectarme a un servidor LDAP que requiere STARTTLS, pero no tengo suerte, cada vez que uso SessionOptions.StartTransportLayerSecurity (..) o establece SessionOptions.SecuresSockElyLayer a verdadero, obtengo excepciones.

Aquí está el código que estoy usando:

using (var connection = new LdapConnection(new LdapDirectoryIdentifier(config.LdapServer, config.Port, false, false)))
{
    connection.SessionOptions.ProtocolVersion = 3;
    connection.Credential = new NetworkCredential(config.BindDN, config.BindPassword);
    connection.SessionOptions.VerifyServerCertificate += (conn, cert) => {return true;};
    connection.AuthType = AuthType.Basic;
    //connection.SessionOptions.SecureSocketLayer = true;
    connection.SessionOptions.StartTransportLayerSecurity(null); // throws here, same if done after bind.
    connection.Bind();

    ... do stuff with connection
}

La excepción resultante es "tlSoperationException: ocurrió un error no especificado", que ocurre al invocar el método StartTransportLayerSecurity.

He probado el código contra Ambos y OpenLDAP Server y Active Directory, pero ninguno funciona.

¿Alguien sabe cómo hacer que StartTLS funcione con System.DirectoryServices?

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top