Link to home
Start Free TrialLog in
Avatar of smita_raut
smita_raut

asked on

Why does ldap_result() API return success even if the LDAP server is not reachable

Hi Experts,

I have a c++ client program that is polling the Sun One directory server for changes. It uses ldap_result() API to wait for the result of LDAP operation. This call is returning 0 (success) in normal scenario when the client program is able to connect to the directory server and is returning -1 (error) when I stop the server, or pull out the network cable of my client machine.

But when I pull out the network cable of the server machine, I still get return value as 0 falsely indicating the client program successful operation. Could anyone throw some light on why this could be happening and that too only in the scenario when the server machine is taken out of network.

Thanks,
Smita
Avatar of cj_1969
cj_1969
Flag of United States of America image

Could be cached information ... can you tell if it is actaully getting data in this case or does it have nothing and is truely a false status?

Stopping the service the client is able to connect to the destination and know that the data is not available.

Unplugging the client network cable is going to disable the network interface on the client machine, this will cause the communications code to fail which will flag the app that it cannot get the data.

Unplugging the server cable will leave the client working and the server just not reachable ... there is a chance that the code is still able to pull the data from a cache or something so that it is not failing.  

Does it return a 0 value for an account that it has never accessed?
Avatar of schalcraft
schalcraft

ldap_result is typically used to obtain the results of a previous ldap function (eg search). If you call the function before the previous has errored ( timed out !) then you may still get a non-error result.

When the previous function returns an error quickly ( because you have a gross comms issue) you pick up the error. You may have to consider performing more error testing, or add some wait states.
Avatar of smita_raut

ASKER

I am doing ldap_search_ext_s followed by ldap_result. So what schalcraft says holds true, that the ldap_search_ext_s is returning successfully and then the server is brought out of network before calling ldap_result.

But then, why does it show success (0) only in this case and not in case when the client is brought out of network or the server is stopped while still on network?
On cj_1969's question "can you tell if it is actaully getting data in this case or does it have nothing and is truely a false status?", the answer is it is not getting the data and is indeed a false status. Even after you connect back the server while the client is still running, it is not able to get the data.
The issue can be resolved by making use of TCP keepalives. For more information on the same please refer to- https://bugzilla.mozilla.org/show_bug.cgi?id=341217

This question could be deleted.

Thanks,
Smita
ASKER CERTIFIED SOLUTION
Avatar of CetusMOD
CetusMOD
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial