Hi All,

We are using Mozilla LDAP C SDK version 5.12. NSPR version 4.2.2. NSS
version 3.7.7.

Using prldap_init instead of ldap_init, for the sake of NSPR I/O.
Setting PRLDAP_OPT_IO_MAX_TIMEOUT to 3 milli seconds, so that, our
application does not block even if Directory Server (DS) hangs or when
there is a delay in network traffic.

We have simulated delay in network traffic by using ProxyWorkbench. We
have simulated DS hang by using faulty plugin to DS.
In both the above cases, LDAP synchronous calls (ldap_modify_ext_s and
ldap_delete_s) are not getting blocked, but returning the status as
LDAP_PARAM_ERROR, instead of LDAP_TIMEOUT.

Here is the sample (Windows) and its output after execution:

--------------

#include "stdio.h"
#include "stdlib.h"
#include <ldap.h>
#include <ldap-standard.h>
#include <ldap_pr.h>


int main(int noArgs, char **args)
{
        if(noArgs != 6){
                printf("Usage: delete host port bindDN bindPwd dn");
                exit(1);
        }

        int retCode = -1;

        char *host = args[1];
        char *port = args[2];
        char *bindDN = args[3];
        char *bindPwd = args[4];
        const char *node = args[5];

        // Establish connection ....
        LDAP *ld = prldap_init(host, atoi(port), 1);

        // Set options...
        const unsigned int uiVerLDAP = LDAP_VERSION3;
        retCode = ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, ( void
* )&uiVerLDAP );
        printf("\nSet option status: %x", retCode);
        if(retCode != 0){
                printf("\nSet option failed");
                exit(1);
        }

        retCode = ldap_simple_bind_s(ld, bindDN, bindPwd);
        printf("\nBind status: %x", retCode);
        if(retCode != 0){
                printf("\nbind failed");
                exit(1);
        }

        retCode = prldap_set_session_option( ld, NULL,
PRLDAP_OPT_IO_MAX_TIMEOUT, 3  );
        printf("\nPRLDAP Set option status: %x", retCode);
        if(retCode != 0){
                printf("\nPRLDAP Set option failed");
                exit(1);
        }

        // Delete...
        printf("\nDelete : %s", node);
        retCode = ldap_delete_s(ld, node);

        printf("\nSync delete operation status: %x", retCode);
        if(retCode != 0){
                printf("\nSynchronous delete operation failed.");
        }

        ldap_unbind(ld);
}

output:
Set option status: 0
Bind status: 0
PRLDAP Set option status: 0
Delete : cn=test001,ou=Policy1,o=company,c=us
Sync delete operation status: 59
Synchronous delete operation failed.

--------------

Note that the output of ldap_delete_s call is 59 (that is
LDAP_PARAM_ERROR).

Also, please note that, if I comment out the code snippet related to
PRLDAP_OPT_IO_MAX_TIMEOUT setting to 3 ms, then this sample returns
LDAP_SUCCESS though it is slow because of ProxyWorkbench in between.

Why LDAP with NSPR I/O is returning  LDAP_PARAM_ERROR, instead of
LDAP_TIMEOUT, when PRLDAP_OPT_IO_MAX_TIMEOUT is set to a some finite
value?

_______________________________________________
dev-tech-ldap mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-ldap

Reply via email to