mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-13 14:27:59 +08:00
Added a conformant sortedResults support which is unable to sort anything.
This commit is contained in:
parent
0b6ed01c05
commit
af866c3b44
@ -32,6 +32,9 @@ static SLAP_CTRL_PARSE_FN parseManageDSAit;
|
||||
static SLAP_CTRL_PARSE_FN parseModifyIncrement;
|
||||
static SLAP_CTRL_PARSE_FN parseNoOp;
|
||||
static SLAP_CTRL_PARSE_FN parsePagedResults;
|
||||
#ifdef LDAP_DEVEL
|
||||
static SLAP_CTRL_PARSE_FN parseSortedResults;
|
||||
#endif
|
||||
static SLAP_CTRL_PARSE_FN parseValuesReturnFilter;
|
||||
static SLAP_CTRL_PARSE_FN parsePermissiveModify;
|
||||
static SLAP_CTRL_PARSE_FN parseDomainScope;
|
||||
@ -112,6 +115,12 @@ static struct slap_control control_defs[] = {
|
||||
(int)offsetof(struct slap_control_ids, sc_pagedResults),
|
||||
SLAP_CTRL_SEARCH, NULL,
|
||||
parsePagedResults, LDAP_SLIST_ENTRY_INITIALIZER(next) },
|
||||
#ifdef LDAP_DEVEL
|
||||
{ LDAP_CONTROL_SORTREQUEST,
|
||||
(int)offsetof(struct slap_control_ids, sc_sortedResults),
|
||||
SLAP_CTRL_GLOBAL|SLAP_CTRL_SEARCH|SLAP_CTRL_HIDE, NULL,
|
||||
parseSortedResults, LDAP_SLIST_ENTRY_INITIALIZER(next) },
|
||||
#endif
|
||||
#ifdef LDAP_CONTROL_X_DOMAIN_SCOPE
|
||||
{ LDAP_CONTROL_X_DOMAIN_SCOPE,
|
||||
(int)offsetof(struct slap_control_ids, sc_domainScope),
|
||||
@ -950,6 +959,34 @@ done:;
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef LDAP_DEVEL
|
||||
static int parseSortedResults (
|
||||
Operation *op,
|
||||
SlapReply *rs,
|
||||
LDAPControl *ctrl )
|
||||
{
|
||||
int rc = LDAP_SUCCESS;
|
||||
|
||||
if ( op->o_sortedresults != SLAP_CONTROL_NONE ) {
|
||||
rs->sr_text = "sorted results control specified multiple times";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
if ( BER_BVISEMPTY( &ctrl->ldctl_value ) ) {
|
||||
rs->sr_text = "sorted results control value is empty (or absent)";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
/* blow off parsing the value */
|
||||
|
||||
op->o_sortedresults = ctrl->ldctl_iscritical
|
||||
? SLAP_CONTROL_CRITICAL
|
||||
: SLAP_CONTROL_NONCRITICAL;
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int parseAssert (
|
||||
Operation *op,
|
||||
SlapReply *rs,
|
||||
|
@ -254,7 +254,9 @@ send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c )
|
||||
* plugin.
|
||||
*/
|
||||
|
||||
if ( o->o_pb && slapi_pblock_get( o->o_pb, SLAPI_RESCONTROLS, &sctrls ) != 0 ) {
|
||||
if ( o->o_pb &&
|
||||
slapi_pblock_get( o->o_pb, SLAPI_RESCONTROLS, &sctrls ) != 0 )
|
||||
{
|
||||
sctrls = NULL;
|
||||
}
|
||||
|
||||
@ -269,10 +271,37 @@ send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c )
|
||||
#ifdef LDAP_SLAPI
|
||||
if ( c != NULL )
|
||||
#endif /* LDAP_SLAPI */
|
||||
for( ; *c != NULL; c++) {
|
||||
rc = send_ldap_control( ber, *c );
|
||||
{
|
||||
for( ; *c != NULL; c++) {
|
||||
rc = send_ldap_control( ber, *c );
|
||||
if( rc == -1 ) return rc;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LDAP_DEVEL
|
||||
/* this is a hack to avoid having to modify op->s_ctrls */
|
||||
if( o->o_sortedresults ) {
|
||||
BerElementBuffer berbuf;
|
||||
BerElement *sber = (BerElement *) &berbuf;
|
||||
LDAPControl sorted;
|
||||
BER_BVZERO( &sorted.ldctl_value );
|
||||
sorted.ldctl_oid = LDAP_CONTROL_SORTRESPONSE;
|
||||
sorted.ldctl_iscritical = 0;
|
||||
|
||||
ber_init2( sber, NULL, LBER_USE_DER );
|
||||
|
||||
ber_printf( sber, "{i}", LDAP_UNWILLING_TO_PERFORM );
|
||||
|
||||
if( ber_flatten2( ber, &sorted.ldctl_value, 0 ) == -1 ) {
|
||||
return LBER_ERROR;
|
||||
}
|
||||
|
||||
(void) ber_free_buf( ber );
|
||||
|
||||
rc = send_ldap_control( ber, &sorted );
|
||||
if( rc == -1 ) return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LDAP_SLAPI
|
||||
if ( sctrls != NULL ) {
|
||||
@ -1405,8 +1434,7 @@ str2result(
|
||||
char *s,
|
||||
int *code,
|
||||
char **matched,
|
||||
char **info
|
||||
)
|
||||
char **info )
|
||||
{
|
||||
int rc;
|
||||
char *c;
|
||||
@ -1567,8 +1595,10 @@ slap_attr_flags( AttributeName *an )
|
||||
flags |= ( SLAP_OPATTRS_NO | SLAP_USERATTRS_YES );
|
||||
|
||||
} else {
|
||||
flags |= an_find( an, &AllOper ) ? SLAP_OPATTRS_YES : SLAP_OPATTRS_NO;
|
||||
flags |= an_find( an, &AllUser ) ? SLAP_USERATTRS_YES : SLAP_USERATTRS_NO;
|
||||
flags |= an_find( an, &AllOper )
|
||||
? SLAP_OPATTRS_YES : SLAP_OPATTRS_NO;
|
||||
flags |= an_find( an, &AllUser )
|
||||
? SLAP_USERATTRS_YES : SLAP_USERATTRS_NO;
|
||||
}
|
||||
|
||||
return flags;
|
||||
|
@ -2166,6 +2166,9 @@ struct slap_control_ids {
|
||||
int sc_modifyIncrement;
|
||||
int sc_noOp;
|
||||
int sc_pagedResults;
|
||||
#ifdef LDAP_DEVEL
|
||||
int sc_sortedResults;
|
||||
#endif
|
||||
int sc_valuesReturnFilter;
|
||||
int sc_permissiveModify;
|
||||
int sc_domainScope;
|
||||
@ -2370,11 +2373,14 @@ typedef struct slap_op {
|
||||
|
||||
#define o_pagedresults o_ctrlflag[slap_cids.sc_pagedResults]
|
||||
#define o_pagedresults_state o_controls[slap_cids.sc_pagedResults]
|
||||
#define get_pagedresults(op) ((int)(op)->o_pagedresults)
|
||||
|
||||
#ifdef LDAP_DEVEL
|
||||
#define o_sortedresults o_ctrlflag[slap_cids.sc_sortedResults]
|
||||
#endif
|
||||
|
||||
#define o_sync o_ctrlflag[slap_cids.sc_LDAPsync]
|
||||
|
||||
#define get_pagedresults(op) ((int)(op)->o_pagedresults)
|
||||
|
||||
AuthorizationInformation o_authz;
|
||||
|
||||
BerElement *o_ber; /* ber of the request */
|
||||
|
Loading…
Reference in New Issue
Block a user