Question

J'essaie de me connecter à un serveur LDAP qui nécessite StartTLS, mais n'ayant pas de chance - chaque fois que j'utilise soit la sessionOptions.StartTransportLayeSecurity (..) ou définissez sessionOptions.SeCureSocketlayer pour true, j'obtiens des exceptions.

Voici le code que j'utilise:

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
}

L'exception résultante est "TLSOperationException: une erreur non spécifiée s'est produite", qui se produit lors de l'invocation de la méthode StartTransportLayeSecurity.

J'ai testé le code contre le serveur OpenLDAP et Active Directory, mais aucun ne fonctionne.

Est-ce que quelqu'un sait comment faire travailler STARTTLS avec System.DirectoryServices?

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top