Check for critical client controls.

This commit is contained in:
Kurt Zeilenga 2001-07-06 03:13:42 +00:00
parent e03f96f093
commit f61152ccbd
11 changed files with 77 additions and 1 deletions

View File

@ -56,8 +56,13 @@ ldap_abandon_ext(
LDAPControl **sctrls, LDAPControl **sctrls,
LDAPControl **cctrls ) LDAPControl **cctrls )
{ {
int rc;
Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 );
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
return do_abandon( ld, msgid, msgid, sctrls, cctrls ); return do_abandon( ld, msgid, msgid, sctrls, cctrls );
} }
@ -77,7 +82,7 @@ int
ldap_abandon( LDAP *ld, int msgid ) ldap_abandon( LDAP *ld, int msgid )
{ {
Debug( LDAP_DEBUG_TRACE, "ldap_abandon %d\n", msgid, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_abandon %d\n", msgid, 0, 0 );
return do_abandon( ld, msgid, msgid, NULL, NULL ) == LDAP_SUCCESS return ldap_abandon_ext( ld, msgid, NULL, NULL ) == LDAP_SUCCESS
? 0 : -1; ? 0 : -1;
} }

View File

@ -105,6 +105,10 @@ ldap_add_ext(
assert( dn != NULL ); assert( dn != NULL );
assert( msgidp != NULL ); assert( msgidp != NULL );
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
/* create a message to send */ /* create a message to send */
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY; ld->ld_errno = LDAP_NO_MEMORY;

View File

@ -51,6 +51,7 @@ ldap_compare_ext(
LDAPControl **cctrls, LDAPControl **cctrls,
int *msgidp ) int *msgidp )
{ {
int rc;
BerElement *ber; BerElement *ber;
Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 );
@ -61,6 +62,10 @@ ldap_compare_ext(
assert( attr != NULL ); assert( attr != NULL );
assert( msgidp != NULL ); assert( msgidp != NULL );
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
/* create a message to send */ /* create a message to send */
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( LDAP_NO_MEMORY ); return( LDAP_NO_MEMORY );

View File

@ -441,3 +441,34 @@ ldap_create_control(
*ctrlp = ctrl; *ctrlp = ctrl;
return LDAP_SUCCESS; return LDAP_SUCCESS;
} }
/*
* check for critical client controls and bitch if present
* if we ever support critical controls, we'll have to
* find a means for maintaining per API call control
* information.
*/
int ldap_int_client_controls( LDAP *ld, LDAPControl **ctrls )
{
LDAPControl *const *c;
assert( ld != NULL );
if( ctrls == NULL ) {
/* use default server controls */
ctrls = ld->ld_cctrls;
}
if( ctrls == NULL || *ctrls == NULL ) {
return LDAP_SUCCESS;
}
for( c = ctrls ; *c != NULL; c++ ) {
if( (*c)->ldctl_iscritical ) {
ld->ld_errno = LDAP_NOT_SUPPORTED;
return ld->ld_errno;
}
}
return LDAP_SUCCESS;
}

View File

@ -45,6 +45,7 @@ ldap_delete_ext(
LDAPControl **cctrls, LDAPControl **cctrls,
int *msgidp ) int *msgidp )
{ {
int rc;
BerElement *ber; BerElement *ber;
Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 );
@ -54,6 +55,10 @@ ldap_delete_ext(
assert( dn != NULL ); assert( dn != NULL );
assert( msgidp != NULL ); assert( msgidp != NULL );
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
/* create a message to send */ /* create a message to send */
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY; ld->ld_errno = LDAP_NO_MEMORY;

View File

@ -367,6 +367,9 @@ LDAP_F (int) ldap_int_put_controls LDAP_P((
LDAPControl *const *ctrls, LDAPControl *const *ctrls,
BerElement *ber )); BerElement *ber ));
LDAP_F (int) ldap_int_client_controls LDAP_P((
LDAP *ld,
LDAPControl **ctrlp ));
/* /*
* in dsparse.c * in dsparse.c

View File

@ -73,6 +73,10 @@ ldap_modify_ext( LDAP *ld,
Debug( LDAP_DEBUG_TRACE, "ldap_modify_ext\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_modify_ext\n", 0, 0, 0 );
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
/* create a message to send */ /* create a message to send */
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( LDAP_NO_MEMORY ); return( LDAP_NO_MEMORY );

View File

@ -70,6 +70,10 @@ ldap_rename(
Debug( LDAP_DEBUG_TRACE, "ldap_rename\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_rename\n", 0, 0, 0 );
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
/* create a message to send */ /* create a message to send */
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
return( LDAP_NO_MEMORY ); return( LDAP_NO_MEMORY );

View File

@ -67,6 +67,10 @@ ldap_sasl_bind(
assert( LDAP_VALID( ld ) ); assert( LDAP_VALID( ld ) );
assert( msgidp != NULL ); assert( msgidp != NULL );
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
if( msgidp == NULL ) { if( msgidp == NULL ) {
ld->ld_errno = LDAP_PARAM_ERROR; ld->ld_errno = LDAP_PARAM_ERROR;
return ld->ld_errno; return ld->ld_errno;

View File

@ -91,6 +91,7 @@ ldap_search_ext(
int sizelimit, int sizelimit,
int *msgidp ) int *msgidp )
{ {
int rc;
BerElement *ber; BerElement *ber;
int timelimit; int timelimit;
@ -99,6 +100,10 @@ ldap_search_ext(
assert( ld != NULL ); assert( ld != NULL );
assert( LDAP_VALID( ld ) ); assert( LDAP_VALID( ld ) );
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
/* /*
* if timeout is provided, both tv_sec and tv_usec must * if timeout is provided, both tv_sec and tv_usec must
* be non-zero * be non-zero

View File

@ -34,6 +34,12 @@ ldap_unbind_ext(
LDAPControl **sctrls, LDAPControl **sctrls,
LDAPControl **cctrls ) LDAPControl **cctrls )
{ {
int rc;
/* check client controls */
rc = ldap_int_client_controls( ld, cctrls );
if( rc != LDAP_SUCCESS ) return rc;
return ldap_ld_free( ld, 1, sctrls, cctrls ); return ldap_ld_free( ld, 1, sctrls, cctrls );
} }