[Date Prev][Date Next] [Chronological] [Thread] [Top]

Use LDAP with or without SSL



Hello,

I am trying to make a c application which can work with or without
SSL(openSSL).

Before i make a simple_bind_s i do
without SSL
    ld = ldap_open(ptPool->pszHostName,ptPool->iPortNo);
    if (ld == NULL){
        rc = CTXLDAP_RC_LDAP;
        goto fin;
    }

with SSL
    ld = ldap_init(ptPool->pszHostName,ptPool->iPortNo);
    if (ld == NULL){
        rc = CTXLDAP_RC_LDAP;
        goto fin;
    }

    {
        int arg = LDAP_OPT_X_TLS_HARD;
        rc = ldap_set_option(ld, LDAP_OPT_X_TLS, &arg);
        if (rc != LDAP_SUCCESS){
            rc = CTXLDAP_RC_LDAP;
            goto fin;
        }
    }

I wonder if there is a "trick" to do the same thing in both case and
let LDAP decide whether i use or not SSL.

Thanks,

Jerome