" -b basedn base dn for search\n"
" -E [!]<ctrl>[=<ctrlparam>] search controls (! indicates criticality)\n"
" [!]mv=<filter> (matched values filter)\n"
-#ifdef LDAP_CONTROL_PAGEDRESULTS
" [!]pr=<size> (paged results)\n"
-#endif
#ifdef LDAP_CONTROL_SUBENTRIES
" [!]subentries[=true|false] (subentries)\n"
#endif
static char *sortattr = NULL;
static int verbose, not, includeufn, vals2tmp, ldif;
-#ifdef LDAP_CONTROL_PAGEDRESULTS
static int pagedResults = 0;
static ber_int_t pageSize = 0;
static ber_int_t entriesLeft = 0;
LDAP *ld,
LDAPMessage *result,
struct berval *cookie );
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
static void
urlize(char *url)
int referrals, timelimit, sizelimit, debug;
int authmethod, version, want_bindpw;
LDAP *ld = NULL;
- int subentries, valuesReturnFilter;
BerElement *ber = NULL;
+ char *control = NULL, *cvalue;
+ int subentries, valuesReturnFilter;
struct berval *sebvalp = NULL, *vrbvalp = NULL;
char *vrFilter = NULL;
- char *control = NULL, *cvalue;
char *pw_file = NULL;
char *authzid = NULL;
-#ifdef LDAP_CONTROL_PAGEDRESULTS
struct berval *prbvalp = NULL;
- int num = 0;
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
-
infile = NULL;
debug = verbose = not = vals2tmp = referrals =
subentries = valuesReturnFilter =
attrsonly = manageDSAit = noop = ldif = want_bindpw = 0;
-#ifdef LDAP_CONTROL_PAGEDRESULTS
npagedresponses = npagedentries = npagedreferences =
npagedextended = npagedpartial = 0;
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
prog = lutil_progname( "ldapsearch", argc, argv );
version = LDAP_VERSION3;
break;
-#ifdef LDAP_CONTROL_PAGEDRESULTS
} else if ( strcasecmp( control, "pr" ) == 0 ) {
- int tmp;
+ int num, tmp;
/* PagedResults control */
if ( pagedResults != 0 ) {
fprintf( stderr, "PagedResultsControl previously specified" );
pageSize = (ber_int_t) tmp;
pagedResults = 1 + crit;
break;
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
#ifdef LDAP_CONTROL_SUBENTRIES
} else if ( strcasecmp( control, "subentries" ) == 0 ) {
}
}
-#ifdef LDAP_CONTROL_PAGEDRESULTS
getNextPage:
- if ( manageDSAit || noop || subentries || valuesReturnFilter || pageSize )
-#else
- if ( manageDSAit || noop || subentries || valuesReturnFilter )
-#endif
+ if ( manageDSAit || noop || subentries
+ || valuesReturnFilter || pageSize )
{
int err;
int i=0;
ctrls[++i] = NULL;
}
-#ifdef LDAP_CONTROL_PAGEDRESULTS
if ( pagedResults ) {
if (( ber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
return EXIT_FAILURE;
ctrls[i] = &c[i];
ctrls[++i] = NULL;
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
ber_bvfree( sebvalp );
ber_bvfree( vrbvalp );
-#ifdef LDAP_CONTROL_PAGEDRESULTS
ber_bvfree( prbvalp );
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
}
if ( verbose ) {
}
}
-#ifdef LDAP_CONTROL_PAGEDRESULTS
if ( ( pageSize != 0 ) && ( morePagedResults != 0 ) ) {
char buf[6];
int i, moreEntries, tmpSize;
buf[i] = '\0';
if ( i > 0 && isdigit( buf[0] ) ) {
- num = sscanf( buf, "%d", &tmpSize );
+ int num = sscanf( buf, "%d", &tmpSize );
if ( num != 1 ) {
fprintf( stderr, "Invalid value for PagedResultsControl, %s.\n", buf);
return EXIT_FAILURE;
goto getNextPage;
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
ldap_unbind( ld );
return( rc );
case LDAP_RES_SEARCH_RESULT:
rc = print_result( ld, msg, 1 );
-#ifdef LDAP_CONTROL_PAGEDRESULTS
if ( pageSize != 0 ) {
rc = parse_page_control( ld, msg, &cookie );
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
goto done;
}
}
}
done:
-#ifdef LDAP_CONTROL_PAGEDRESULTS
if ( pageSize != 0 ) {
npagedresponses = npagedresponses + nresponses;
npagedentries = npagedentries + nentries;
if( npartial ) printf( "# numPartial: %d\n", npagedpartial );
if( nreferences ) printf( "# numReferences: %d\n", npagedreferences );
}
- } else
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
- if ( ldif < 2 ) {
+ } else if ( ldif < 2 ) {
printf( "\n# numResponses: %d\n", nresponses );
if( nentries ) printf( "# numEntries: %d\n", nentries );
if( nextended ) printf( "# numExtended: %d\n", nextended );
}
-#ifdef LDAP_CONTROL_PAGEDRESULTS
static int
parse_page_control(
LDAP *ld,
return err;
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
char *control, *cvalue;
int crit;
- int id;
- LDAPMessage *res;
char *matcheddn = NULL, *text = NULL, **refs = NULL;
char *retoid = NULL;
struct berval *retdata = NULL;
{
static char *controls[] = {
LDAP_CONTROL_MANAGEDSAIT,
-#ifdef LDAP_CONTROL_SUBENTRIES
- LDAP_CONTROL_SUBENTRIES,
-#endif
-#ifdef LDAP_CONTROL_NOOP
LDAP_CONTROL_NOOP,
-#endif
-#ifdef LDAP_CONTROL_VALUESRETURNFILTER
+ LDAP_CONTROL_PAGEDRESULTS,
LDAP_CONTROL_VALUESRETURNFILTER,
+#ifdef LDAP_CONTROL_SUBENTRIES
+ LDAP_CONTROL_SUBENTRIES,
#endif
#ifdef LDAP_CLIENT_UPDATE
LDAP_CONTROL_CLIENT_UPDATE,
#endif
-#ifdef LDAP_CONTROL_PAGEDRESULTS
- LDAP_CONTROL_PAGEDRESULTS,
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
NULL
};
int scope,
int deref,
ID *ids );
-#ifdef LDAP_CONTROL_PAGEDRESULTS
static void send_pagerequest_response(
Connection *conn,
Operation *op,
ID lastid,
int nentries,
int tentries );
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
int
bdb_search(
struct berval realbase = { 0, NULL };
int nentries = 0;
int manageDSAit;
-#ifdef LDAP_CONTROL_PAGEDRESULTS
int pagedresults;
int tentries = 0;
ID lastid = NOID;
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
#ifdef LDAP_CLIENT_UPDATE
Filter lcupf, csnfnot, csnfeq, csnfand, csnfge;
manageDSAit = get_manageDSAit( op );
-
-#ifdef LDAP_CONTROL_PAGEDRESULTS
pagedresults = get_pagedresults( op );
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
rc = LOCK_ID (bdb->bi_dbenv, &locker );
switch(rc) {
/* if no limit is required, use soft limit */
if ( slimit <= 0 ) {
-#ifdef LDAP_CONTROL_PAGEDRESULTS
if ( pagedresults && limit->lms_s_pr != 0 ) {
slimit = limit->lms_s_pr;
} else {
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
slimit = limit->lms_s_soft;
-#ifdef LDAP_CONTROL_PAGEDRESULTS
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
/* if requested limit higher than hard limit, abort */
} else if ( slimit > limit->lms_s_hard ) {
}
}
-#ifdef LDAP_CONTROL_PAGEDRESULTS
if ( isroot || !limit->lms_s_pr_hide ) {
tentries = BDB_IDL_N(candidates);
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
-#ifdef LDAP_CONTROL_PAGEDRESULTS
if ( pagedresults ) {
if ( op->o_pagedresults_state.ps_cookie == 0 ) {
id = 0;
}
goto loop_begin;
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
#ifdef LDAP_CLIENT_UPDATE
if ( op->o_clientupdate_type & SLAP_LCUP_SYNC ) {
int scopeok = 0;
-#ifdef LDAP_CONTROL_PAGEDRESULTS
loop_begin:
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
-
/* check for abandon */
if ( op->o_abandon ) {
rc = 0;
v2refs, NULL, nentries );
goto done;
}
-#ifdef LDAP_CONTROL_PAGEDRESULTS
+
if ( pagedresults ) {
if ( nentries >= op->o_pagedresults_size ) {
send_pagerequest_response( conn, op, lastid, nentries, tentries );
}
lastid = id;
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
if (e) {
int result;
return rc;
}
-#ifdef LDAP_CONTROL_PAGEDRESULTS
static void
send_pagerequest_response(
Connection *conn,
ch_free( ctrls[0]->ldctl_value.bv_val );
}
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
0,
- -1 /* no limit on unchecked size */
-#ifdef LDAP_CONTROL_PAGEDRESULTS
- ,
+ -1, /* no limit on unchecked size */
0, /* page limit */
0 /* hide number of entries left */
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
};
AccessControl *global_acl = NULL;
SLAP_CTRL_SEARCH, NULL,
parseSubentries },
#endif
-#ifdef LDAP_CONTROL_NOOP
{ LDAP_CONTROL_NOOP,
SLAP_CTRL_ACCESS, NULL,
parseNoOp },
-#endif
-#ifdef LDAP_CONTROL_PAGEDRESULTS
{ LDAP_CONTROL_PAGEDRESULTS,
SLAP_CTRL_SEARCH, NULL,
parsePagedResults },
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
-#ifdef LDAP_CONTROL_VALUESRETURNFILTER
{ LDAP_CONTROL_VALUESRETURNFILTER,
SLAP_CTRL_SEARCH, NULL,
parseValuesReturnFilter },
-#endif
#ifdef LDAP_CLIENT_UPDATE
{ LDAP_CONTROL_CLIENT_UPDATE,
SLAP_CTRL_SEARCH, NULL,
}
#endif
-#ifdef LDAP_CONTROL_NOOP
static int parseNoOp (
Connection *conn,
Operation *op,
return LDAP_SUCCESS;
}
-#endif
-#ifdef LDAP_CONTROL_PAGEDRESULTS
static int parsePagedResults (
Connection *conn,
Operation *op,
return LDAP_SUCCESS;
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
-#ifdef LDAP_CONTROL_VALUESRETURNFILTER
int parseValuesReturnFilter (
Connection *conn,
Operation *op,
return LDAP_SUCCESS;
}
-#endif
#ifdef LDAP_CLIENT_UPDATE
static int parseClientUpdate (
LDAP_CONTROL_REFERRALS,
#endif /* LDAP_CONTROL_REFERRALS */
-#ifdef LDAP_CONTROL_MANAGEDSAIT
LDAP_CONTROL_MANAGEDSAIT,
-#endif /* LDAP_CONTROL_MANAGEDSAIT */
#ifdef LDAP_CONTROL_SUBENTRIES
LDAP_CONTROL_SUBENTRIES,
#endif /* LDAP_CONTROL_SUBENTRIES */
-#ifdef LDAP_CONTROL_NOOP
LDAP_CONTROL_NOOP,
-#endif /* LDAP_CONTROL_NOOP */
#ifdef LDAP_CONTROL_DUPENT_REQUEST
LDAP_CONTROL_DUPENT_REQUEST,
LDAP_CONTROL_DUPENT_ENTRY,
#endif /* LDAP_CONTROL_DUPENT_ENTRY */
-#ifdef LDAP_CONTROL_PAGEDRESULTS
LDAP_CONTROL_PAGEDRESULTS,
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
#ifdef LDAP_CONTROL_SORTREQUEST
LDAP_CONTROL_SORTREQUEST,
LDAP_CONTROL_VLVRESPONSE,
#endif /* LDAP_CONTROL_VLVRESPONSE */
-#ifdef LDAP_CONTROL_VALUESRETURNFILTER
LDAP_CONTROL_VALUESRETURNFILTER,
-#endif /* LDAP_CONTROL_VALUESRETURNFILTER */
-
NULL
};
}
}
-#ifdef LDAP_CONTROL_PAGEDRESULTS
} else if ( strncasecmp( arg, "pr", sizeof( "pr" ) - 1 ) == 0 ) {
arg += sizeof( "pr" ) - 1;
if ( arg[0] != '=' ) {
return( 1 );
}
}
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
} else {
return( 1 );
int lms_s_soft;
int lms_s_hard;
int lms_s_unchecked;
-#ifdef LDAP_CONTROL_PAGEDRESULTS
int lms_s_pr;
int lms_s_pr_hide;
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
};
struct slap_limits {
#define get_manageDSAit(op) ((int)(op)->o_managedsait)
#define get_subentries(op) ((int)(op)->o_subentries)
#define get_subentries_visibility(op) ((int)(op)->o_subentries_visibility)
-#ifdef LDAP_CONTROL_PAGEDRESULTS
-#define get_pagedresults(op) ((int)(op)->o_pagedresults)
-#endif /* LDAP_CONTROL_PAGEDRESULTS */
+#define get_pagedresults(op) ((int)(op)->o_pagedresults)
/*