#include "../../libraries/liblber/lber-int.h"
char *supportedControls[] = {
+ LDAP_CONTROL_MANAGEDSAIT,
NULL
};
BerElement *ber = op->o_ber;
LDAPControl ***ctrls = &op->o_ctrls;
int rc = LDAP_SUCCESS;
+ char *errmsg = NULL;
len = ber_pvt_ber_remaining(ber);
if(( tag = ber_peek_tag( ber, &len )) != LDAP_TAG_CONTROLS ) {
if( tag == LBER_ERROR ) {
- rc = LDAP_PROTOCOL_ERROR;
+ rc = -1;
+ errmsg = "unexpected data in PDU";
}
goto return_results;
}
if( op->o_protocol < LDAP_VERSION3 ) {
- rc = LDAP_PROTOCOL_ERROR;
+ rc = -1;
+ errmsg = "controls require LDAPv3";
goto return_results;
}
#if 0
if( *ctrls == NULL ) {
rc = LDAP_NO_MEMORY;
+ errmsg = "no memory";
goto return_results;
}
#endif
*ctrls = NULL;
rc = LDAP_NO_MEMORY;
+ errmsg = "no memory";
goto return_results;
}
#endif
if( tag == LBER_ERROR ) {
*ctrls = NULL;
ldap_controls_free( tctrls );
- rc = LDAP_DECODING_ERROR;
+ rc = -1;
+ errmsg = "decoding controls error";
goto return_results;
}
!charray_inlist( supportedControls, tctrl->ldctl_oid ) )
{
rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
+ errmsg = "critical extension is unavailable ";
goto return_results;
}
return_results:
if( sendres && rc != LDAP_SUCCESS ) {
- send_ldap_result( conn, op, rc, NULL, NULL );
+ if( rc == -1 ) {
+ send_ldap_disconnect( conn, op, rc, errmsg );
+ } else {
+ send_ldap_result( conn, op, rc,
+ NULL, errmsg, NULL, NULL );
+ }
}
return rc;
}
+
+
+int get_manageDSAit( Operation *op )
+{
+ int i;
+ if( op == NULL || op->o_ctrls == NULL ) {
+ return 0;
+ }
+
+ for( i=0; op->o_ctrls[i] != NULL; i++ ) {
+ if( strcmp( LDAP_CONTROL_MANAGEDSAIT, op->o_ctrls[i]->ldctl_oid )
+ == 0 )
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
\ No newline at end of file