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

Re: Protocol Error with ldap_bind_s



On Fri, 11 Mar 2005 Christophe.Senzot@steria.be wrote:

Hi,

I'm trying to use the C API to connect to  LDAP but I always get a
"protocol error" (return code = 2) when executing the ldap_simple_bind_s
function.
Here is the source, can anyone help me ?


int version = LDAP_VERSION3; /* Assuming you want LDAPv3 */

m_LDAP = ldap_init( HOST_IP , LDAP_PORT );
if( m_LDAP == NULL )
{
    printf("ldap_init error\n");
    return 1;
}


if (ldap_set_option(m_LDAP, LDAP_OPT_PROTOCOL_VERSION, &version) != LDAP_SUCCESS) { printf("ldap_set_option error\n"); return 1; }

ulRet = ldap_simple_bind_s( m_LDAP, NULL, NULL) ;
if( ulRet != LDAP_SUCCESS )
{
    printf("ldap_simple_bind_s <%s> (%d)\n", ldap_err2string(ulRet),
ulRet);
    ldap_unbind( m_LDAP);
    return ulRet;
}

-> the error message I have is "ldap_simple_bind_s <Protocol Error> (2)"

Any advice would be appreciate, thanks in advance.

Studying the source code for ldapsearch in the OpenLDAP distribution is an excellent way to start out writing clients.


Christophe.

-- Kirk Turner-Rustin | Programmer/Analyst Ohio Wesleyan University | Libraries and Information Services http://www.owu.edu | http://lis.owu.edu