1 /* schema_init.c - init builtin schema */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
19 #define berValidate blobValidate
25 /* any value allowed */
36 unsigned char *u = in->bv_val;
38 for( count = in->bv_len; count > 0; count-=len, u+=len ) {
39 /* get the length indicated by the first byte */
40 len = LDAP_UTF8_CHARLEN( u );
42 /* should not be zero */
43 if( len == 0 ) return -1;
45 /* make sure len corresponds with the offset
46 to the next character */
47 if( LDAP_UTF8_OFFSET( u ) != len ) return -1;
50 if( count != 0 ) return -1;
61 struct berval **normalized )
63 struct berval *newval;
66 newval = ch_malloc( sizeof( struct berval ) );
70 /* Ignore initial whitespace */
71 while ( ldap_utf8_isspace( p ) ) {
80 newval->bv_val = ch_strdup( p );
81 p = q = newval->bv_val;
87 if ( ldap_utf8_isspace( p ) ) {
88 len = LDAP_UTF8_COPY(q,p);
93 /* Ignore the extra whitespace */
94 while ( ldap_utf8_isspace( p ) ) {
98 len = LDAP_UTF8_COPY(q,p);
105 assert( *newval->bv_val );
106 assert( newval->bv_val < p );
109 /* cannot start with a space */
110 assert( !ldap_utf8_isspace(newval->bv_val) );
113 * If the string ended in space, backup the pointer one
114 * position. One is enough because the above loop collapsed
115 * all whitespace to a single space.
122 /* cannot end with a space */
123 assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) );
128 newval->bv_len = q - newval->bv_val;
129 *normalized = newval;
141 if( val->bv_len == 0 ) return 0;
143 if( isdigit(val->bv_val[0]) ) {
145 for(i=1; i < val->bv_len; i++) {
146 if( val->bv_val[i] == '.' ) {
147 if( dot++ ) return 1;
148 } else if ( isdigit(val->bv_val[i]) ) {
157 } else if( isalpha(val->bv_val[0]) ) {
158 for(i=1; i < val->bv_len; i++) {
159 if( !isalpha(val->bv_val[i] ) ) {
177 for(i=0; i < val->bv_len; i++) {
178 if( !isdigit(val->bv_val[i]) ) return -1;
185 printableStringValidate(
191 for(i=0; i < val->bv_len; i++) {
192 if( !isprint(val->bv_val[i]) ) return -1;
205 for(i=0; i < val->bv_len; i++) {
206 if( !isascii(val->bv_val[i]) ) return -1;
216 struct berval **out )
219 ber_len_t i, len = in->bv_len;
220 struct berval *bv = ch_malloc( sizeof(struct berval) );
222 bv->bv_len = len * sizeof( ldap_unicode_t );
223 bv->bv_val = (char *) u = ch_malloc( bv->bv_len + sizeof( ldap_unicode_t ) );;
225 for(i=0; i < len; i++ ) {
227 * IA5StringValidate should have been called to ensure
228 * input is limited to IA5.
230 u[i] = in->bv_val[i];
244 struct berval **normalized )
246 struct berval *newval;
249 newval = ch_malloc( sizeof( struct berval ) );
253 /* Ignore initial whitespace */
254 while ( isspace( *p++ ) ) {
263 newval->bv_val = ch_strdup( p );
264 p = q = newval->bv_val;
267 if ( isspace( *p ) ) {
270 /* Ignore the extra whitespace */
271 while ( isspace( *p++ ) ) {
279 assert( *newval->bv_val );
280 assert( newval->bv_val < p );
283 /* cannot start with a space */
284 assert( !isspace(*newval->bv_val) );
287 * If the string ended in space, backup the pointer one
288 * position. One is enough because the above loop collapsed
289 * all whitespace to a single space.
292 if ( isspace( q[-1] ) ) {
296 /* cannot end with a space */
297 assert( !isspace( q[-1] ) );
302 newval->bv_len = q - newval->bv_val;
303 *normalized = newval;
313 struct berval *value,
314 void *assertedValue )
316 return strcmp( value->bv_val,
317 ((struct berval *) assertedValue)->bv_val );
325 struct berval *value,
326 void *assertedValue )
328 return strcasecmp( value->bv_val,
329 ((struct berval *) assertedValue)->bv_val );
337 struct berval *value,
338 void *assertedValue )
340 ObjectClass *oc = oc_find( value->bv_val );
341 ObjectClass *asserted = oc_find( ((struct berval *) assertedValue)->bv_val );
343 return oc == NULL || oc != asserted;
346 struct syntax_defs_rec {
349 slap_syntax_validate_func *sd_validate;
350 slap_syntax_transform_func *sd_ber2str;
351 slap_syntax_transform_func *sd_str2ber;
354 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
355 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
357 struct syntax_defs_rec syntax_defs[] = {
358 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
359 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
360 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
361 0, NULL, NULL, NULL},
362 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
363 0, NULL, NULL, NULL},
364 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
365 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
366 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
367 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
368 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
369 0, NULL, NULL, NULL},
370 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
371 0, NULL, NULL, NULL},
372 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
373 X_BINARY X_NOT_H_R ")",
374 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
375 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
376 X_BINARY X_NOT_H_R ")",
377 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
378 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
379 X_BINARY X_NOT_H_R ")",
380 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
381 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
382 0, NULL, NULL, NULL},
383 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'DN' )",
384 0, blobValidate, NULL, NULL},
385 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
386 0, NULL, NULL, NULL},
387 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
388 0, NULL, NULL, NULL},
389 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
390 0, UTF8StringValidate, NULL, NULL},
391 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
392 0, NULL, NULL, NULL},
393 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
394 0, NULL, NULL, NULL},
395 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
396 0, NULL, NULL, NULL},
397 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
398 0, NULL, NULL, NULL},
399 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
400 0, NULL, NULL, NULL},
401 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
402 0, blobValidate, NULL, NULL},
403 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
404 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
405 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
406 0, NULL, NULL, NULL},
407 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
408 0, NULL, NULL, NULL},
409 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
410 0, IA5StringValidate, NULL, NULL},
411 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
412 0, integerValidate, NULL, NULL},
413 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
414 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
415 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
416 0, NULL, NULL, NULL},
417 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
418 0, NULL, NULL, NULL},
419 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
420 0, NULL, NULL, NULL},
421 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
422 0, NULL, NULL, NULL},
423 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
424 0, NULL, NULL, NULL},
425 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
426 0, NULL, NULL, NULL},
427 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
428 0, NULL, NULL, NULL},
429 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
430 0, NULL, NULL, NULL},
431 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
432 0, NULL, NULL, NULL},
433 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
434 0, oidValidate, NULL, NULL},
435 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
436 0, NULL, NULL, NULL},
437 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
438 0, blobValidate, NULL, NULL},
439 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
440 0, blobValidate, NULL, NULL},
441 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
442 0, NULL, NULL, NULL},
443 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
444 0, NULL, NULL, NULL},
445 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
446 0, printableStringValidate, NULL, NULL},
447 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
448 X_BINARY X_NOT_H_R ")",
449 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
450 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
451 0, blobValidate, NULL, NULL},
452 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
453 0, NULL, NULL, NULL},
454 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
455 0, NULL, NULL, NULL},
456 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
457 0, NULL, NULL, NULL},
458 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
459 0, NULL, NULL, NULL},
460 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
461 0, NULL, NULL, NULL},
462 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
463 0, NULL, NULL, NULL},
464 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
465 0, NULL, NULL, NULL},
466 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
467 0, NULL, NULL, NULL},
469 /* OpenLDAP Experimental Syntaxes */
470 {"( " SLAPD_OID_ACI_SYNTAX " DESC 'OpenLDAP Experimental ACI' )",
471 0, NULL, NULL, NULL},
473 {NULL, 0, NULL, NULL, NULL}
476 struct mrule_defs_rec {
479 slap_mr_convert_func * mrd_convert;
480 slap_mr_normalize_func * mrd_normalize;
481 slap_mr_match_func * mrd_match;
482 slap_mr_indexer_func * mrd_indexer;
483 slap_mr_filter_func * mrd_filter;
487 * Other matching rules in X.520 that we do not use:
489 * 2.5.13.9 numericStringOrderingMatch
490 * 2.5.13.13 booleanMatch
491 * 2.5.13.15 integerOrderingMatch
492 * 2.5.13.18 octetStringOrderingMatch
493 * 2.5.13.19 octetStringSubstringsMatch
494 * 2.5.13.25 uTCTimeMatch
495 * 2.5.13.26 uTCTimeOrderingMatch
496 * 2.5.13.31 directoryStringFirstComponentMatch
497 * 2.5.13.32 wordMatch
498 * 2.5.13.33 keywordMatch
499 * 2.5.13.34 certificateExactMatch
500 * 2.5.13.35 certificateMatch
501 * 2.5.13.36 certificatePairExactMatch
502 * 2.5.13.37 certificatePairMatch
503 * 2.5.13.38 certificateListExactMatch
504 * 2.5.13.39 certificateListMatch
505 * 2.5.13.40 algorithmIdentifierMatch
506 * 2.5.13.41 storedPrefixMatch
507 * 2.5.13.42 attributeCertificateMatch
508 * 2.5.13.43 readerAndKeyIDMatch
509 * 2.5.13.44 attributeIntegrityMatch
512 /* recycled matching functions */
513 #define caseIgnoreMatch caseIgnoreIA5Match
514 #define caseExactMatch caseExactIA5Match
516 /* unimplemented matching functions */
517 #define objectIdentifierMatch NULL
518 #define distinguishedNameMatch NULL
519 #define caseIgnoreOrderingMatch NULL
520 #define caseIgnoreSubstringsMatch NULL
521 #define caseExactOrderingMatch NULL
522 #define caseExactSubstringsMatch NULL
523 #define numericStringMatch NULL
524 #define numericStringSubstringsMatch NULL
525 #define caseIgnoreListMatch NULL
526 #define caseIgnoreListSubstringsMatch NULL
527 #define integerMatch NULL
528 #define bitStringMatch NULL
529 #define octetStringMatch NULL
530 #define telephoneNumberMatch NULL
531 #define telephoneNumberSubstringsMatch NULL
532 #define presentationAddressMatch NULL
533 #define uniqueMemberMatch NULL
534 #define protocolInformationMatch NULL
535 #define generalizedTimeMatch NULL
536 #define generalizedTimeOrderingMatch NULL
537 #define integerFirstComponentMatch NULL
538 #define objectIdentifierFirstComponentMatch NULL
539 #define caseIgnoreIA5SubstringsMatch NULL
541 struct mrule_defs_rec mrule_defs[] = {
542 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
543 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
544 SLAP_MR_EQUALITY | SLAP_MR_EXT,
545 NULL, NULL, objectIdentifierMatch, NULL, NULL},
547 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
548 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
549 SLAP_MR_EQUALITY | SLAP_MR_EXT,
550 NULL, NULL, distinguishedNameMatch, NULL, NULL},
552 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
553 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
554 SLAP_MR_EQUALITY | SLAP_MR_EXT,
555 NULL, UTF8StringNormalize, caseIgnoreMatch, NULL, NULL},
557 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
558 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
560 NULL, UTF8StringNormalize, caseIgnoreOrderingMatch, NULL, NULL},
562 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
563 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
564 SLAP_MR_SUBSTR | SLAP_MR_EXT,
565 NULL, UTF8StringNormalize, caseIgnoreSubstringsMatch, NULL, NULL},
567 /* Next three are not in the RFC's, but are needed for compatibility */
568 {"( 2.5.13.5 NAME 'caseExactMatch' "
569 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
570 SLAP_MR_EQUALITY | SLAP_MR_EXT,
571 NULL, UTF8StringNormalize, caseExactMatch, NULL, NULL},
573 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
574 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
576 NULL, UTF8StringNormalize, caseExactOrderingMatch, NULL, NULL},
578 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
579 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
580 SLAP_MR_SUBSTR | SLAP_MR_EXT,
581 NULL, UTF8StringNormalize, caseExactSubstringsMatch, NULL, NULL},
583 {"( 2.5.13.8 NAME 'numericStringMatch' "
584 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
585 SLAP_MR_EQUALITY | SLAP_MR_EXT,
586 NULL, NULL, numericStringMatch, NULL, NULL},
588 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
589 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
590 SLAP_MR_SUBSTR | SLAP_MR_EXT,
591 NULL, NULL, numericStringSubstringsMatch, NULL, NULL},
593 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
594 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
595 SLAP_MR_EQUALITY | SLAP_MR_EXT,
596 NULL, NULL, caseIgnoreListMatch, NULL, NULL},
598 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
599 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
600 SLAP_MR_SUBSTR | SLAP_MR_EXT,
601 NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
603 {"( 2.5.13.14 NAME 'integerMatch' "
604 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
605 SLAP_MR_NONE | SLAP_MR_EXT,
606 NULL, NULL, integerMatch, NULL, NULL},
608 {"( 2.5.13.16 NAME 'bitStringMatch' "
609 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
610 SLAP_MR_NONE | SLAP_MR_EXT,
611 NULL, NULL, bitStringMatch, NULL, NULL},
613 {"( 2.5.13.17 NAME 'octetStringMatch' "
614 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
615 SLAP_MR_EQUALITY | SLAP_MR_EXT,
616 NULL, NULL, octetStringMatch, NULL, NULL},
618 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
619 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
620 SLAP_MR_EQUALITY | SLAP_MR_EXT,
621 NULL, NULL, telephoneNumberMatch, NULL, NULL},
623 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
624 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
625 SLAP_MR_SUBSTR | SLAP_MR_EXT,
626 NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
628 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
629 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
630 SLAP_MR_NONE | SLAP_MR_EXT,
631 NULL, NULL, presentationAddressMatch, NULL, NULL},
633 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
634 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
635 SLAP_MR_NONE | SLAP_MR_EXT,
636 NULL, NULL, uniqueMemberMatch, NULL, NULL},
638 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
639 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
640 SLAP_MR_NONE | SLAP_MR_EXT,
641 NULL, NULL, protocolInformationMatch, NULL, NULL},
643 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
644 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
645 SLAP_MR_EQUALITY | SLAP_MR_EXT,
646 NULL, NULL, generalizedTimeMatch, NULL, NULL},
648 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
649 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
651 NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
653 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
654 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
655 SLAP_MR_EQUALITY | SLAP_MR_EXT,
656 NULL, NULL, integerFirstComponentMatch, NULL, NULL},
658 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
659 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
660 SLAP_MR_EQUALITY | SLAP_MR_EXT,
661 NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
663 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
664 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
665 SLAP_MR_EQUALITY | SLAP_MR_EXT,
666 NULL, IA5StringNormalize, caseExactIA5Match, NULL, NULL},
668 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
669 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
670 SLAP_MR_EQUALITY | SLAP_MR_EXT,
671 NULL, IA5StringNormalize, caseIgnoreIA5Match, NULL, NULL},
673 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
674 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
676 NULL, IA5StringNormalize, caseIgnoreIA5SubstringsMatch, NULL, NULL},
678 {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
681 static int schema_init_done = 0;
689 /* we should only be called once (from main) */
690 assert( schema_init_done == 0 );
692 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
693 res = register_syntax( syntax_defs[i].sd_desc,
694 syntax_defs[i].sd_flags,
695 syntax_defs[i].sd_validate,
696 syntax_defs[i].sd_ber2str,
697 syntax_defs[i].sd_str2ber );
700 fprintf( stderr, "schema_init: Error registering syntax %s\n",
701 syntax_defs[i].sd_desc );
706 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
707 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
709 "schema_init: Ingoring unusable matching rule %s\n",
710 mrule_defs[i].mrd_desc );
714 res = register_matching_rule(
715 mrule_defs[i].mrd_desc,
716 mrule_defs[i].mrd_usage,
717 mrule_defs[i].mrd_convert,
718 mrule_defs[i].mrd_normalize,
719 mrule_defs[i].mrd_match,
720 mrule_defs[i].mrd_indexer,
721 mrule_defs[i].mrd_filter );
725 "schema_init: Error registering matching rule %s\n",
726 mrule_defs[i].mrd_desc );
730 schema_init_done = 1;
734 #ifdef SLAPD_SCHEMA_NOT_COMPAT
735 struct slap_internal_schema slap_schema;
737 struct slap_schema_oc_map {
741 { "alias", offsetof(struct slap_internal_schema, si_oc_alias) },
742 { "referral", offsetof(struct slap_internal_schema, si_oc_referral) },
746 struct slap_schema_ad_map {
748 slap_mr_match_func *ssam_match;
751 { "objectClass", objectClassMatch,
752 offsetof(struct slap_internal_schema, si_ad_objectClass) },
754 { "creatorsName", NULL,
755 offsetof(struct slap_internal_schema, si_ad_creatorsName) },
756 { "createTimestamp", NULL,
757 offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
758 { "modifiersName", NULL,
759 offsetof(struct slap_internal_schema, si_ad_modifiersName) },
760 { "modifyTimestamp", NULL,
761 offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
763 { "subschemaSubentry", NULL,
764 offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
766 { "namingContexts", NULL,
767 offsetof(struct slap_internal_schema, si_ad_namingContexts) },
768 { "supportedControl", NULL,
769 offsetof(struct slap_internal_schema, si_ad_supportedControl) },
770 { "supportedExtension", NULL,
771 offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
772 { "supportedLDAPVersion", NULL,
773 offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
774 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
775 { "supportedACIMechanisms", NULL,
776 offsetof(struct slap_internal_schema, si_ad_supportedACIMechanisms) },
779 { "supportedSASLMechanisms", NULL,
780 offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
782 { "attributeTypes", NULL,
783 offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
784 { "ldapSyntaxes", NULL,
785 offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
786 { "matchingRules", NULL,
787 offsetof(struct slap_internal_schema, si_ad_matchingRules) },
788 { "objectClasses", NULL,
789 offsetof(struct slap_internal_schema, si_ad_objectClasses) },
792 offsetof(struct slap_internal_schema, si_ad_ref) },
795 offsetof(struct slap_internal_schema, si_ad_entry) },
797 offsetof(struct slap_internal_schema, si_ad_children) },
799 { "userPassword", NULL,
800 offsetof(struct slap_internal_schema, si_ad_userPassword) },
801 { "authPassword", NULL,
802 offsetof(struct slap_internal_schema, si_ad_authPassword) },
803 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
805 offsetof(struct slap_internal_schema, si_ad_krbName) },
816 #ifdef SLAPD_SCHEMA_NOT_COMPAT
819 /* we should only be called once after schema_init() was called */
820 assert( schema_init_done == 1 );
822 #ifdef SLAPD_SCHEMA_NOT_COMPAT
823 for( i=0; oc_map[i].ssom_name; i++ ) {
824 ObjectClass ** ocp = (ObjectClass **)
825 &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
827 *ocp = oc_find( oc_map[i].ssom_name );
831 "No objectClass \"%s\" defined in schema\n",
832 oc_map[i].ssom_name );
833 return LDAP_OBJECT_CLASS_VIOLATION;
837 for( i=0; ad_map[i].ssam_name; i++ ) {
841 AttributeDescription ** adp = (AttributeDescription **)
842 &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
846 rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
848 if( rc != LDAP_SUCCESS ) {
850 "No attribute \"%s\" defined in schema\n",
851 ad_map[i].ssam_name );
855 if( ad_map[i].ssam_match ) {
856 /* install custom matching routine */
857 (*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;