• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 462
  • Last Modified:

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.

1 Solution
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?
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.
smita_rautAuthor Commented:
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?
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

smita_rautAuthor Commented:
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.
smita_rautAuthor Commented:
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.

PAQed with points refunded (200)

Community Support Moderator

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now