[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: using ldap_get_values_len (ITS#3318)



Kurt,

I have written a client that uses the following code to parse the ldap results
--------------------------------------------------------------------------
    // retrieve the attribute values and create the attribute object
    for (attr=ldap_first_attribute(ld, entry,&ber);
        attr !=NULL;
        attr=ldap_next_attribute(ld, entry, ber))
    {
         printf("attr = %d\n",attr);
        if ((vals =ldap_get_values_len(ld,entry,attr)) != NULL)
        {
            printf("val = %d\n",vals);
			// creating an object of values
            if ((tmp_attr=new DGLdapAttributeImpl(attr,vals)) != NULL)
            {
			// add the attr object to a vector
                attributes->push_back(tmp_attr);
                //(*attributes)[count++]=tmp_attr;

            }
            ldap_value_free_len(vals);
        }
        else
        {
            char tmp_err[ERR_STR_LEN];
            // get the ldap return code and throw an exception. Since I could
		// not get an error I decided to set one myself
            int rc=LDAP_OPERATIONS_ERROR;
            strcpy(tmp_err,ldap_err2string(rc));
            CRDEBUG(DG_VERBOSE, ("ldap_value_free_len failure rc=%d, errString=%
s",rc,tmp_err));
            DGLdapException LdapFailure(SEARCH_FAIL, tmp_err,rc);
            throw(LdapFailure);


        }

        ldap_memfree(attr);

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

What I am finding is that when a query is sent to the server with no attributes
and a filter of (objectclass=*). sometimes I receive back a full set of values
and sometimes the vals object is NIL. I assumed that the ldap result object
would have an error result but I dont seem to be able to retrieve any errors.
This is being done in a mutithreaded program but the LDAP connection object is
not being shared across threads. ie each thread establishes their own connection.

Am I doing something wrong or is there an issue with openldap where the results
returned from a default openldap server with a BDB are not always consistent.

Kirk

On 9/2/2004 8:15 PM, Kurt Zeilenga wrote:
> It is not clear from your message precise what issue you are
> attempting to report.  Please be more specific, including
> sufficient information such that a developer could recreate
> the issue.  Also, you should verify that whatever issue you
> have exists in the latest release (or at least the latest
> "stable" release) of OpenLDAP Software.
>