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

ldap() in shared objects...



I have compiled a shared object (PAM module to be exact) which utilizes some ldap() API calls. I have noticed a discrepency in making a call to ldap_simple_bind_s().

According to the man pages for ldap_simple_bind_s() I need to do a check against LDAP_SUCCESS as a returned status message.

here is the code I am using for a regular binary:
/* open a connection & failover if necessary */
z = 0;
ld = ldap_init( servs[z], LDAP_PORT );
while( ldap_simple_bind_s( ld, "username", "password" ) != LDAP_SUCCESS ) {
rc = ldap_result( ld, msgid, z, &zerotime, &res );
if( ( z < 5 ) || ( rc == -1 ) ) {
ld = ldap_init( servs[z], LDAP_PORT );
}
printf( "Bind failed on: %s\n", servs[z]);
z++;
}
ldap_perror( ld, "ldap_simple_bind_s");


This works fine, now if I perform the same check as a shared object any attempt to check against LDAP_SUCCESS fails, as of yet i have only been able to do the following to get it to work:

/* open a connection & failover if necessary */
   z = 0;
   ld = ldap_init( servs[z], LDAP_PORT );
   while( ! ldap_simple_bind_s( ld, "ldapaccess", "access6ldap" ) ) {
       rc = ldap_result( ld, msgid, z, &zerotime, &res );
       if( ( z < 5 ) || ( rc == -1 ) ) {
           ld = ldap_init( servs[z], LDAP_PORT );
       }
       printf( "Bind failed on: %s\n", servs[z]);
       z++;
   }
   ldap_perror( ld, "ldap_simple_bind_s");

has anyone else ran into this problem?

here are my compile commands if this is necessary:
binary: gcc -o search ldap.c -lldap
shared object: gcc -fPIC -o pam_ldap.o -c pam_ldap.c
ld -x --shared -o pam_ldap.so pam_ldap.o -lpam -lldap


--
Jason Gerfen
jason.Gerfen@scl.utah.edu

"...Sometimes I just yell at myself. And it
makes me sad, sometimes I make myself cry..."
			~ My nephew Dawsyn