Hi,
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 LDAP_CALL LDAP_CALLBACK 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, -"kalyan"
S Kalyanasundaram wrote:
Hi,
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 LDAP_CALL LDAP_CALLBACK 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, -"kalyan"
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.
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.
Yeh, somehow i missed to see that versions. Thanks for pointing out. However i got the following from my ldap.h
/* V3 REBIND Function Callback Prototype */ typedef int (LDAP_REBIND_PROC) LDAP_P(( LDAP *ld, LDAP_CONST char *url, ber_tag_t request, ber_int_t msgid, void *params ));
ld - handle url - ldap:// or ldaps://...
what about the remaining arguments? How it is used? now where will i give my authentication details?
I guess this url will have referral value returned from the ldap server. So i dont need set it anything on this.
If somebody had done already please give me some idea.
Thanks, -"kalyan"
openldap-software@openldap.org