• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • 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?
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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