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

Posted on 2006-06-02
Last Modified: 2012-06-21
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.

Question by:smita_raut
    LVL 22

    Expert Comment

    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?
    LVL 2

    Expert Comment

    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.

    Author Comment

    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?

    Author Comment

    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.

    Author Comment

    The issue can be resolved by making use of TCP keepalives. For more information on the same please refer to-

    This question could be deleted.


    Accepted Solution

    PAQed with points refunded (200)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    Title # Comments Views Activity
    Microsoft Dynamics Roles question 4 27
    How to Upload data on VPS ? 4 54
    Visual xHarbour 1 48
    Dropbox 3 40
    Let’s list some of the technologies that enable smooth teleworking. 
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    The viewer will learn how to set up a document for the web and print and the recommended PPI for printing.
    The viewer will learn how to back up with the free utility from runtime software, DriveImageXML using Windows 8. Download DriveImageXML from Open folder where it was saved: Start installation by double clicking the install scrip…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now