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

Re: How to chase referrals

S Kalyanasundaram wrote:

What i have done this,

char *ldap_username="xx";
char *ldap_password="xx";

        if( ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON) != 0) {
                log_error("LDAP set Optoin for referral");
        if( ldap_set_rebind_proc(ld, get_rebind, NULL) != 0) {
                log_error("LDAP set Optoin for rebind");

static int
get_rebind( LDAP *ld, char **whop, char **credp,int *methodp, int freeit, void* arg )
         if ( !freeit ) {
                *whop = ldap_username;
                *credp = ldap_password;
                *methodp = LDAP_AUTH_SIMPLE;
        return( LDAP_SUCCESS );

This cause be Segfault. I traced with gdb when it reaches this function get_rebind it gives like "credb" address is ox63 and methodp is 0x2. I dont understand why the low address has come up for these variables.

Then i added the following,
static int
get_rebind ...

but it gives me the compilation error. What i am missing here. Can you find something odd here.

thanks a lot for your help,

Look at the actual definition of ldap_set_rebind_proc() in <ldap.h>. It takes a pointer to a function of type LDAP_REBIND_PROC. Your get_rebind() function doesn't match that type. Actually the compiler should complain about a type mismatch error in your call to ldap_set_rebind_proc, surprising that it didn't. Are you using the right set of header files that matches your library? It looks like you're using the old LDAPv2 style rebind call, not the current LDAPv3 API.

  -- Howard Chu
  Chief Architect, Symas Corp.  http://www.symas.com
  Director, Highland Sun        http://highlandsun.com/hyc
  OpenLDAP Core Team            http://www.openldap.org/project/