On Wed, Jun 8, 2016 at 5:13 PM, Christos Papoulas <pachris...@gmail.com>
wrote:

> Hello list,
>
> Is it possible to pass a certificate file like ssl-cert.pem to the
> LdapConnectionConfig? My sample code right now is:
>
> are you connecting to Apache Directory Server? if yes, then certificate
based authentication is
not supported.

If you are connecting to any other server that supports certificate based
authentication then
you need to set the TrustManager and KeyManager in LdapConnectionConfig

> public static LdapConnection createConnection(String host, int port,
>             String user, String pass, boolean useSSL, boolean useSSLv3)
> throws IOException, LdapException {
>         LdapConnectionConfig connectionConfig = new
> LdapConnectionConfig();
>
>         if (host == null || host.isEmpty()) {
>             throw new IllegalArgumentException("Hostname is not
> specified");
>         }
>         if(port <= 0) {
>             throw new IllegalArgumentException("The ldap port is not
> valid");
>         }
>         connectionConfig.setLdapHost(host);
>         connectionConfig.setLdapPort(port);
>
>         if(user!= null && user.length() > 0) {
>             connectionConfig.setName(user);
>         }
>         if(pass != null && pass.length() > 0) {
>             connectionConfig.setCredentials(pass);
>         }
>         if(useSSL == true) {
>             connectionConfig.setUseSsl(true);
>         }
>         if(useSSLv3 == true) {
>             connectionConfig.setSslProtocol("SSLv3");
>         }
>         LdapConnection connection = new
> LdapNetworkConnection(connectionConfig);
>
>         connection.connect();
>         connection.bind();
>
>         return connection;
> }
>
Kiran Ayyagari
http://keydap.com

Reply via email to