- if ((c->re) &&
- (regexec(c->re, bv->bv_val, 0, NULL, 0) == REG_NOMATCH))
- return LDAP_CONSTRAINT_VIOLATION; /* regular expression violation */
-
- if ((c->size) && (bv->bv_len > c->size))
- return LDAP_CONSTRAINT_VIOLATION; /* size violation */
-
- if (c->lud) {
- Operation nop = *op;
- slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
- slap_callback cb;
- int i;
- int found = 0;
- int rc;
- size_t len;
- struct berval filterstr;
- char *ptr;
-
- cb.sc_next = NULL;
- cb.sc_response = constraint_uri_cb;
- cb.sc_cleanup = NULL;
- cb.sc_private = &found;
-
- nop.o_protocol = LDAP_VERSION3;
- nop.o_tag = LDAP_REQ_SEARCH;
- nop.o_time = slap_get_time();
- if (c->lud->lud_dn) {
- struct berval dn;
-
- ber_str2bv(c->lud->lud_dn, 0, 0, &dn);
- nop.o_req_dn = dn;
- nop.o_req_ndn = dn;
- nop.o_bd = select_backend(&nop.o_req_ndn, 1 );
- if (!nop.o_bd) {
- return LDAP_NO_SUCH_OBJECT; /* unexpected error */
+ switch (c->type) {
+ case CONSTRAINT_SIZE:
+ if (bv->bv_len > c->size)
+ return LDAP_CONSTRAINT_VIOLATION; /* size violation */
+ break;
+ case CONSTRAINT_REGEX:
+ if (regexec(c->re, bv->bv_val, 0, NULL, 0) == REG_NOMATCH)
+ return LDAP_CONSTRAINT_VIOLATION; /* regular expression violation */
+ break;
+ case CONSTRAINT_URI: {
+ Operation nop = *op;
+ slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
+ slap_callback cb;
+ int i;
+ int found = 0;
+ int rc;
+ size_t len;
+ struct berval filterstr;
+ char *ptr;
+
+ cb.sc_next = NULL;
+ cb.sc_response = constraint_uri_cb;
+ cb.sc_cleanup = NULL;
+ cb.sc_private = &found;
+
+ nop.o_protocol = LDAP_VERSION3;
+ nop.o_tag = LDAP_REQ_SEARCH;
+ nop.o_time = slap_get_time();
+ if (c->lud->lud_dn) {
+ struct berval dn;
+
+ ber_str2bv(c->lud->lud_dn, 0, 0, &dn);
+ nop.o_req_dn = dn;
+ nop.o_req_ndn = dn;
+ nop.o_bd = select_backend(&nop.o_req_ndn, 1 );
+ if (!nop.o_bd) {
+ return LDAP_NO_SUCH_OBJECT; /* unexpected error */
+ }
+ if (!nop.o_bd->be_search) {
+ return LDAP_OTHER; /* unexpected error */
+ }
+ } else {
+ nop.o_req_dn = nop.o_bd->be_nsuffix[0];
+ nop.o_req_ndn = nop.o_bd->be_nsuffix[0];
+ nop.o_bd = on->on_info->oi_origdb;