[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
ldap_search_st() problem
I'm having a problem with ldap_seach_st().
I am attempting to call a function that does the following:
1. Opens a connection to a LDAP server
2. Does a LDAP Bind - where who = password = NULL
3. Does a LDAP search w/ timeout
4. Gets first enrty
5. Gets first attribute
6. Gets fist value
7. unbinds
8. function returns
I have a piece of code that works and one that does not.
Both ways work on the first call, but only the first code works on
subsequent calls.
The second piece of code returns NULL from ldap_first_entry. I'm not sure
why the first code does not cause a segmentation fault.
Code sample 1:
struct timeval tv;
...
/* open, bind here */
...
tv.sec = 10;
tv.usec = 0;
ldap_search_st(ld, searchbase, LDAP_SCOPE_ONELEVEL, filter, 0, &tv,
&result);
free(tv);
e = ldap_first_entry(ld,result);
...
/* do remaining steps, unbind return from function */
Code sample 2:
struct timeval *tv;
...
/* open, bind here */
...
tv = (struct timeval*)malloc(sizeof(struct timeval));
tv->sec = 10;
tv->usec = 0;
ldap_search_st(ld, searchbase, LDAP_SCOPE_ONELEVEL, filter, 0, &tv,
&result);
free(tv);
e = ldap_first_entry(ld,result);
...
/* do remaining steps, unbind return from function */
------------------- end of code samples ---------------
>From trying several different pieces of code the key seems to be to free(tv)
where tv is declared as the struct not a pointer to the struct.
Any insight to this problem?
Note - this is on Solaris.
Thanks in advance,
-Ash
-------------------------
Ashley Neal Hornbeck
Splitrock Services, Inc.
281.465.1318