- a->ai_type = ch_strdup( attrs[i] );
-#ifdef SLAPD_SCHEMA_COMPAT
- a->ai_syntaxmask = attr_syntax( a->ai_type );
-#endif
- if ( argc == 1 ) {
- a->ai_indexmask = (INDEX_PRESENCE | INDEX_EQUALITY |
- INDEX_APPROX | INDEX_SUB);
- } else {
- a->ai_indexmask = 0;
- for ( j = 0; indexes[j] != NULL; j++ ) {
- if ( strncasecmp( indexes[j], "pres", 4 )
- == 0 ) {
- a->ai_indexmask |= INDEX_PRESENCE;
- } else if ( strncasecmp( indexes[j], "eq", 2 )
- == 0 ) {
- a->ai_indexmask |= INDEX_EQUALITY;
- } else if ( strncasecmp( indexes[j], "approx",
- 6 ) == 0 ) {
- a->ai_indexmask |= INDEX_APPROX;
- } else if ( strncasecmp( indexes[j], "sub", 3 )
- == 0 ) {
- a->ai_indexmask |= INDEX_SUB;
- } else if ( strncasecmp( indexes[j], "none", 4 )
- == 0 ) {
- if ( a->ai_indexmask != 0 ) {
- fprintf( stderr,
-"%s: line %d: index type \"none\" cannot be combined with other types\n",
- fname, lineno );
- }
- a->ai_indexmask = 0;
- } else {
- fprintf( stderr,
- "%s: line %d: unknown index type \"%s\" (ignored)\n",
- fname, lineno, indexes[j] );
- fprintf( stderr,
- "valid index types are \"pres\", \"eq\", \"approx\", or \"sub\"\n" );
- }
- }
+
+ ad = NULL;
+ rc = slap_str2ad( attrs[i], &ad, &text );
+
+ if( rc != LDAP_SUCCESS ) {
+ fprintf( stderr, "%s: line %d: "
+ "index attribute \"%s\" undefined\n",
+ fname, lineno, attrs[i] );
+ return rc;
+ }
+
+ if( slap_ad_is_binary( ad ) ) {
+ fprintf( stderr, "%s: line %d: "
+ "index of attribute \"%s\" disallowed\n",
+ fname, lineno, attrs[i] );
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
+
+ if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) && !(
+ ( ad->ad_type->sat_approx
+ && ad->ad_type->sat_approx->smr_indexer
+ && ad->ad_type->sat_approx->smr_filter )
+ && ( ad->ad_type->sat_equality
+ && ad->ad_type->sat_equality->smr_indexer
+ && ad->ad_type->sat_equality->smr_filter ) ) )
+ {
+ fprintf( stderr, "%s: line %d: "
+ "approx index of attribute \"%s\" disallowed\n",
+ fname, lineno, attrs[i] );
+ return LDAP_INAPPROPRIATE_MATCHING;