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

private search methods not working



Hi All,
We are using Openldap-2.1.25 with our own private backend. I have my own implementation of back-null methods all which does is reads the entry from a file and returns.  

when the client application calls ldap_search,  I see my private search method (null_back_search) is being called and but the results are somehow not being printing on the client screen (where i run ldap_search). It just doesnt' do anything and simply returns. 

I doubt if I am calling the send_search_result or send_search_entry correctly. Have already spent several days researching the code. will appreciate any help. 
thanks, 
-indu
idas@lucent.com 

int
null_back_search(
        BackendDB               *be,
        Connection              *conn,
        Operation               *op,
        struct berval   *base,
        struct berval   *nbase,
        int                             scope,
        int                             deref,
        int                             slimit,
        int                             tlimit,
        Filter                  *filter,
        struct berval   *filterstr,
        AttributeName   *attrs,
        int                             attrsonly )
{
        FILE *rfp = fopen("/maytag/home/idas/openldap-2.1.25/example/add.ldif",
"r");
        int     bsize, len;
        char    *buf, *bp;
        char    line[BUFSIZ];
        Entry   *e;
        int     err;
        char    *matched, *info;

        /* read in the result and send it along */
        buf = (char *) ch_malloc( BUFSIZ );
        buf[0] = '\0';
        bsize = BUFSIZ;
        bp = buf;
        while ( !feof(fp) ) {
                errno = 0;
                if ( fgets( line, sizeof(line), fp ) == NULL ) {
                        if ( errno == EINTR ) continue;

                        break;
                }

                /* ignore lines beginning with # (LDIFv1 comments) */
                if ( *line == '#' ) {
                        continue;
                }

                /* ignore lines beginning with DEBUG: */
                if ( strncasecmp( line, "DEBUG:", 6 ) == 0 ) {
                        continue;
                }

                len = strlen( line );
                while ( bp + len - buf > bsize ) {
                        size_t offset = bp - buf;
                        bsize += BUFSIZ;
                        buf = (char *) ch_realloc( buf, bsize );
                        bp = &buf[offset];
                }
                strcpy( bp, line );
                bp += len;
                /* line marked the end of an entry or result */
                if ( *line == '\n' ) {
                        if ( strncasecmp( buf, "RESULT", 6 ) == 0 ) {
                                break;
                        }

                        if ( (e = str2entry( buf )) == NULL ) {
                                Debug( LDAP_DEBUG_ANY, "str2entry(%s) failed\n",
                                    buf, 0, 0 );
                        } else {
                                send_search_entry( be, conn, op, e, attrs, attrs
only, NULL );
                                entry_free( e );
                        }

                        bp = buf;
                }
        }

        send_search_entry( be, conn, op, e, attrs, attrsonly, NULL );
        send_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL, 0 );

        (void) str2result( buf, &err, &matched, &info );

        /* otherwise, front end will send this result  */
        if ( err != 0 || op->o_tag != LDAP_REQ_BIND ) {
                send_ldap_result( conn, op, err, matched, info, NULL, NULL );
        }
        free( buf );

        return( err );
}