Back to index

openldap  2.4.31
rdnval.c
Go to the documentation of this file.
00001 /* rdnval.c - RDN value overlay */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * Portions Copyright 2008 Pierangelo Masarati.
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted only as authorized by the OpenLDAP
00011  * Public License.
00012  *
00013  * A copy of this license is available in the file LICENSE in the
00014  * top-level directory of the distribution or, alternatively, at
00015  * <http://www.OpenLDAP.org/license.html>.
00016  */
00017 /* ACKNOWLEDGEMENTS:
00018  * This work was initially developed by Pierangelo Masarati
00019  * for inclusion in OpenLDAP Software.
00020  */
00021 
00022 #include "portable.h"
00023 
00024 #ifdef SLAPD_OVER_RDNVAL
00025 
00026 #include <stdio.h>
00027 
00028 #include "ac/string.h"
00029 #include "ac/socket.h"
00030 
00031 #include "slap.h"
00032 #include "config.h"
00033 
00034 #include "lutil.h"
00035 
00036 /*
00037  * Maintain an attribute (rdnValue) that contains the values of each AVA
00038  * that builds up the RDN of an entry.  This is required for interoperation
00039  * with Samba4.  It mimics the "name" attribute provided by Active Directory.
00040  * The naming attributes must be directoryString-valued, or compatible.
00041  * For example, IA5String values are cast into directoryString unless
00042  * consisting of the empty string ("").
00043  */
00044 
00045 static AttributeDescription *ad_rdnValue;
00046 static Syntax               *syn_IA5String;
00047 
00048 static slap_overinst               rdnval;
00049 
00050 static int
00051 rdnval_is_valid( AttributeDescription *desc, struct berval *value )
00052 {
00053        if ( desc->ad_type->sat_syntax == slap_schema.si_syn_directoryString ) {
00054               return 1;
00055        }
00056 
00057        if ( desc->ad_type->sat_syntax == syn_IA5String
00058               && !BER_BVISEMPTY( value ) )
00059        {
00060               return 1;
00061        }
00062 
00063        return 0;
00064 }
00065 
00066 static int
00067 rdnval_unique_check_cb( Operation *op, SlapReply *rs )
00068 {
00069        if ( rs->sr_type == REP_SEARCH ) {
00070               int *p = (int *)op->o_callback->sc_private;
00071               (*p)++;
00072        }
00073 
00074        return 0;
00075 }
00076 
00077 static int
00078 rdnval_unique_check( Operation *op, BerVarray vals )
00079 {
00080        slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
00081 
00082        BackendDB db = *op->o_bd;
00083        Operation op2 = *op;
00084        SlapReply rs2 = { 0 };
00085        int i;
00086        BerVarray fvals;
00087        char *ptr;
00088        int gotit = 0;
00089        slap_callback cb = { 0 };
00090 
00091        /* short-circuit attempts to add suffix entry */
00092        if ( op->o_tag == LDAP_REQ_ADD
00093               && be_issuffix( op->o_bd, &op->o_req_ndn ) )
00094        {
00095               return LDAP_SUCCESS;
00096        }
00097 
00098        op2.o_bd = &db;
00099        op2.o_bd->bd_info = (BackendInfo *)on->on_info;
00100        op2.o_tag = LDAP_REQ_SEARCH;
00101        op2.o_dn = op->o_bd->be_rootdn;
00102        op2.o_ndn = op->o_bd->be_rootndn;
00103        op2.o_callback = &cb;
00104        cb.sc_response = rdnval_unique_check_cb;
00105        cb.sc_private = (void *)&gotit;
00106 
00107        dnParent( &op->o_req_ndn, &op2.o_req_dn );
00108        op2.o_req_ndn = op2.o_req_dn;
00109 
00110        op2.ors_limit = NULL;
00111        op2.ors_slimit = 1;
00112        op2.ors_tlimit = SLAP_NO_LIMIT;
00113        op2.ors_attrs = slap_anlist_no_attrs;
00114        op2.ors_attrsonly = 1;
00115        op2.ors_deref = LDAP_DEREF_NEVER;
00116        op2.ors_scope = LDAP_SCOPE_ONELEVEL;
00117 
00118        for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ )
00119               /* just count */ ;
00120 
00121        fvals = op->o_tmpcalloc( sizeof( struct berval ), i + 1,
00122               op->o_tmpmemctx );
00123 
00124        op2.ors_filterstr.bv_len = 0;
00125        if ( i > 1 ) {
00126               op2.ors_filterstr.bv_len = STRLENOF( "(&)" );
00127        }
00128 
00129        for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ ) {
00130               ldap_bv2escaped_filter_value_x( &vals[ i ], &fvals[ i ],
00131                      1, op->o_tmpmemctx );
00132               op2.ors_filterstr.bv_len += ad_rdnValue->ad_cname.bv_len
00133                      + fvals[ i ].bv_len + STRLENOF( "(=)" );
00134        }
00135 
00136        op2.ors_filterstr.bv_val = op->o_tmpalloc( op2.ors_filterstr.bv_len + 1, op->o_tmpmemctx );
00137 
00138        ptr = op2.ors_filterstr.bv_val;
00139        if ( i > 1 ) {
00140               ptr = lutil_strcopy( ptr, "(&" );
00141        }
00142        for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ ) {
00143               *ptr++ = '(';
00144               ptr = lutil_strncopy( ptr, ad_rdnValue->ad_cname.bv_val, ad_rdnValue->ad_cname.bv_len );
00145               *ptr++ = '=';
00146               ptr = lutil_strncopy( ptr, fvals[ i ].bv_val, fvals[ i ].bv_len );
00147               *ptr++ = ')';
00148        }
00149 
00150        if ( i > 1 ) {
00151               *ptr++ = ')';
00152        }
00153        *ptr = '\0';
00154 
00155        assert( ptr == op2.ors_filterstr.bv_val + op2.ors_filterstr.bv_len );
00156        op2.ors_filter = str2filter_x( op, op2.ors_filterstr.bv_val );
00157        assert( op2.ors_filter != NULL );
00158 
00159        (void)op2.o_bd->be_search( &op2, &rs2 );
00160 
00161        filter_free_x( op, op2.ors_filter, 1 );
00162        op->o_tmpfree( op2.ors_filterstr.bv_val, op->o_tmpmemctx );
00163        for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ ) {
00164               if ( vals[ i ].bv_val != fvals[ i ].bv_val ) {
00165                      op->o_tmpfree( fvals[ i ].bv_val, op->o_tmpmemctx );
00166               }
00167        }
00168        op->o_tmpfree( fvals, op->o_tmpmemctx );
00169 
00170        if ( rs2.sr_err != LDAP_SUCCESS || gotit > 0 ) {
00171               return LDAP_CONSTRAINT_VIOLATION;
00172        }
00173 
00174        return LDAP_SUCCESS;
00175 }
00176 
00177 static int
00178 rdnval_rdn2vals(
00179        Operation *op,
00180        SlapReply *rs,
00181        struct berval *dn,
00182        struct berval *ndn,
00183        BerVarray *valsp,
00184        BerVarray *nvalsp,
00185        int *numvalsp )
00186 {
00187        LDAPRDN rdn = NULL, nrdn = NULL;
00188        int nAVA, i;
00189 
00190        assert( *valsp == NULL );
00191        assert( *nvalsp == NULL );
00192 
00193        *numvalsp = 0;
00194 
00195        if ( ldap_bv2rdn_x( dn, &rdn, (char **)&rs->sr_text,
00196               LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) )
00197        {
00198               Debug( LDAP_DEBUG_TRACE,
00199                      "%s rdnval: can't figure out "
00200                      "type(s)/value(s) of rdn DN=\"%s\"\n",
00201                      op->o_log_prefix, dn->bv_val, 0 );
00202               rs->sr_err = LDAP_INVALID_DN_SYNTAX;
00203               rs->sr_text = "unknown type(s) used in RDN";
00204 
00205               goto done;
00206        }
00207 
00208        if ( ldap_bv2rdn_x( ndn, &nrdn,
00209               (char **)&rs->sr_text, LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) )
00210        {
00211               Debug( LDAP_DEBUG_TRACE,
00212                      "%s rdnval: can't figure out "
00213                      "type(s)/value(s) of normalized rdn DN=\"%s\"\n",
00214                      op->o_log_prefix, ndn->bv_val, 0 );
00215               rs->sr_err = LDAP_INVALID_DN_SYNTAX;
00216               rs->sr_text = "unknown type(s) used in RDN";
00217 
00218               goto done;
00219        }
00220 
00221        for ( nAVA = 0; rdn[ nAVA ]; nAVA++ )
00222               /* count'em */ ;
00223 
00224        /* NOTE: we assume rdn and nrdn contain the same AVAs! */
00225 
00226        *valsp = SLAP_CALLOC( sizeof( struct berval ), nAVA + 1 );
00227        *nvalsp = SLAP_CALLOC( sizeof( struct berval ), nAVA + 1 );
00228 
00229        /* Add new attribute values to the entry */
00230        for ( i = 0; rdn[ i ]; i++ ) {
00231               AttributeDescription *desc = NULL;
00232 
00233               rs->sr_err = slap_bv2ad( &rdn[ i ]->la_attr,
00234                      &desc, &rs->sr_text );
00235 
00236               if ( rs->sr_err != LDAP_SUCCESS ) {
00237                      Debug( LDAP_DEBUG_TRACE,
00238                             "%s rdnval: %s: %s\n",
00239                             op->o_log_prefix,
00240                             rs->sr_text, 
00241                             rdn[ i ]->la_attr.bv_val );
00242                      goto done;
00243               }
00244 
00245               if ( !rdnval_is_valid( desc, &rdn[ i ]->la_value ) ) {
00246                      Debug( LDAP_DEBUG_TRACE,
00247                             "%s rdnval: syntax of naming attribute '%s' "
00248                             "not compatible with directoryString",
00249                             op->o_log_prefix, rdn[ i ]->la_attr.bv_val, 0 );
00250                      continue;
00251               }
00252 
00253               if ( value_find_ex( desc,
00254                             SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
00255                                    SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
00256                             *nvalsp,
00257                             &nrdn[ i ]->la_value,
00258                             op->o_tmpmemctx )
00259                      == LDAP_NO_SUCH_ATTRIBUTE )
00260               {
00261                      ber_dupbv( &(*valsp)[ *numvalsp ], &rdn[ i ]->la_value );
00262                      ber_dupbv( &(*nvalsp)[ *numvalsp ], &nrdn[ i ]->la_value );
00263 
00264                      (*numvalsp)++;
00265               }
00266        }
00267 
00268        if ( rdnval_unique_check( op, *valsp ) != LDAP_SUCCESS ) {
00269               rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
00270               rs->sr_text = "rdnValue not unique within siblings";
00271               goto done;
00272        }
00273 
00274 done:;
00275        if ( rdn != NULL ) {
00276               ldap_rdnfree_x( rdn, op->o_tmpmemctx );
00277        }
00278 
00279        if ( nrdn != NULL ) {
00280               ldap_rdnfree_x( nrdn, op->o_tmpmemctx );
00281        }
00282 
00283        if ( rs->sr_err != LDAP_SUCCESS ) {
00284               if ( *valsp != NULL ) {
00285                      ber_bvarray_free( *valsp );
00286                      ber_bvarray_free( *nvalsp );
00287                      *valsp = NULL;
00288                      *nvalsp = NULL;
00289                      *numvalsp = 0;
00290               }
00291        }
00292 
00293        return rs->sr_err;
00294 }
00295 
00296 static int
00297 rdnval_op_add( Operation *op, SlapReply *rs )
00298 {
00299        Attribute *a, **ap;
00300        int numvals = 0;
00301        BerVarray vals = NULL, nvals = NULL;
00302        int rc;
00303 
00304        /* NOTE: should we accept an entry still in mods format? */
00305        assert( op->ora_e != NULL );
00306 
00307        if ( BER_BVISEMPTY( &op->ora_e->e_nname ) ) {
00308               return SLAP_CB_CONTINUE;
00309        }
00310 
00311        a = attr_find( op->ora_e->e_attrs, ad_rdnValue );
00312        if ( a != NULL ) {
00313               /* TODO: check consistency? */
00314               return SLAP_CB_CONTINUE;
00315        }
00316 
00317        rc = rdnval_rdn2vals( op, rs, &op->ora_e->e_name, &op->ora_e->e_nname,
00318               &vals, &nvals, &numvals );
00319        if ( rc != LDAP_SUCCESS ) {
00320               send_ldap_result( op, rs );
00321        }
00322 
00323        a = attr_alloc( ad_rdnValue );
00324 
00325        a->a_vals = vals;
00326        a->a_nvals = nvals;
00327        a->a_numvals = numvals;
00328 
00329        for ( ap = &op->ora_e->e_attrs; *ap != NULL; ap = &(*ap)->a_next )
00330               /* goto tail */ ;
00331 
00332        *ap = a;
00333 
00334        return SLAP_CB_CONTINUE;
00335 }
00336 
00337 static int
00338 rdnval_op_rename( Operation *op, SlapReply *rs )
00339 {
00340        Modifications *ml, **mlp;
00341        int numvals = 0;
00342        BerVarray vals = NULL, nvals = NULL;
00343        struct berval old;
00344        int rc;
00345 
00346        dnRdn( &op->o_req_dn, &old );
00347        if ( dn_match( &old, &op->orr_newrdn ) ) {
00348               dnRdn( &op->o_req_ndn, &old );
00349               if ( dn_match( &old, &op->orr_nnewrdn ) ) {
00350                      return SLAP_CB_CONTINUE;
00351               }
00352        }
00353 
00354        rc = rdnval_rdn2vals( op, rs, &op->orr_newrdn, &op->orr_nnewrdn,
00355               &vals, &nvals, &numvals );
00356        if ( rc != LDAP_SUCCESS ) {
00357               send_ldap_result( op, rs );
00358        }
00359 
00360        ml = SLAP_CALLOC( sizeof( Modifications ), 1 );
00361        ml->sml_values = vals;
00362        ml->sml_nvalues = nvals;
00363 
00364        ml->sml_numvals = numvals;
00365 
00366        ml->sml_op = LDAP_MOD_REPLACE;
00367        ml->sml_flags = SLAP_MOD_INTERNAL;
00368        ml->sml_desc = ad_rdnValue;
00369        ml->sml_type = ad_rdnValue->ad_cname;
00370 
00371        for ( mlp = &op->orr_modlist; *mlp != NULL; mlp = &(*mlp)->sml_next )
00372               /* goto tail */ ;
00373 
00374        *mlp = ml;
00375 
00376        return SLAP_CB_CONTINUE;
00377 }
00378 
00379 static int
00380 rdnval_db_init(
00381        BackendDB     *be,
00382        ConfigReply   *cr)
00383 {
00384        if ( SLAP_ISGLOBALOVERLAY( be ) ) {
00385               Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
00386                      "rdnval_db_init: rdnval cannot be used as global overlay.\n" );
00387               return 1;
00388        }
00389 
00390        if ( be->be_nsuffix == NULL ) {
00391               Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
00392                      "rdnval_db_init: database must have suffix\n" );
00393               return 1;
00394        }
00395 
00396        if ( BER_BVISNULL( &be->be_rootndn ) || BER_BVISEMPTY( &be->be_rootndn ) ) {
00397               Log1( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
00398                      "rdnval_db_init: missing rootdn for database DN=\"%s\", YMMV\n",
00399                      be->be_suffix[ 0 ].bv_val );
00400        }
00401 
00402        return 0;
00403 }
00404 
00405 typedef struct rdnval_mod_t {
00406        struct berval ndn;
00407        BerVarray vals;
00408        BerVarray nvals;
00409        int numvals;
00410        struct rdnval_mod_t *next;
00411 } rdnval_mod_t;
00412 
00413 typedef struct {
00414        BackendDB *bd;
00415        rdnval_mod_t *mods;
00416 } rdnval_repair_cb_t;
00417 
00418 static int
00419 rdnval_repair_cb( Operation *op, SlapReply *rs )
00420 {
00421        int rc;
00422        rdnval_repair_cb_t *rcb = op->o_callback->sc_private;
00423        rdnval_mod_t *mod;
00424        BerVarray vals = NULL, nvals = NULL;
00425        int numvals = 0;
00426        ber_len_t len;
00427        BackendDB *save_bd = op->o_bd;
00428 
00429        switch ( rs->sr_type ) {
00430        case REP_SEARCH:
00431               break;
00432 
00433        case REP_SEARCHREF:
00434        case REP_RESULT:
00435               return rs->sr_err;
00436 
00437        default:
00438               assert( 0 );
00439        }
00440 
00441        assert( rs->sr_entry != NULL );
00442 
00443        op->o_bd = rcb->bd;
00444        rc = rdnval_rdn2vals( op, rs, &rs->sr_entry->e_name, &rs->sr_entry->e_nname,
00445               &vals, &nvals, &numvals );
00446        op->o_bd = save_bd;
00447        if ( rc != LDAP_SUCCESS ) {
00448               return 0;
00449        }
00450 
00451        len = sizeof( rdnval_mod_t ) + rs->sr_entry->e_nname.bv_len + 1;
00452        mod = op->o_tmpalloc( len, op->o_tmpmemctx );
00453        mod->ndn.bv_len = rs->sr_entry->e_nname.bv_len;
00454        mod->ndn.bv_val = (char *)&mod[1];
00455        lutil_strncopy( mod->ndn.bv_val, rs->sr_entry->e_nname.bv_val, rs->sr_entry->e_nname.bv_len );
00456        mod->vals = vals;
00457        mod->nvals = nvals;
00458        mod->numvals = numvals;
00459 
00460        mod->next = rcb->mods;
00461        rcb->mods = mod;
00462 
00463        Debug( LDAP_DEBUG_TRACE, "%s: rdnval_repair_cb: scheduling entry DN=\"%s\" for repair\n",
00464               op->o_log_prefix, rs->sr_entry->e_name.bv_val, 0 );
00465 
00466        return 0;
00467 }
00468 
00469 static int
00470 rdnval_repair( BackendDB *be )
00471 {
00472        slap_overinst *on = (slap_overinst *)be->bd_info;
00473        void *ctx = ldap_pvt_thread_pool_context();
00474        Connection conn = { 0 };
00475        OperationBuffer opbuf;
00476        Operation *op;
00477        BackendDB db;
00478        slap_callback sc = { 0 };
00479        rdnval_repair_cb_t rcb = { 0 };
00480        SlapReply rs = { REP_RESULT };
00481        rdnval_mod_t *rmod;
00482        int nrepaired = 0;
00483 
00484        connection_fake_init2( &conn, &opbuf, ctx, 0 );
00485        op = &opbuf.ob_op;
00486 
00487        op->o_tag = LDAP_REQ_SEARCH;
00488        memset( &op->oq_search, 0, sizeof( op->oq_search ) );
00489 
00490        assert( !BER_BVISNULL( &be->be_nsuffix[ 0 ] ) );
00491 
00492        op->o_bd = select_backend( &be->be_nsuffix[ 0 ], 0 );
00493        assert( op->o_bd != NULL );
00494        assert( op->o_bd->be_nsuffix != NULL );
00495 
00496        op->o_req_dn = op->o_bd->be_suffix[ 0 ];
00497        op->o_req_ndn = op->o_bd->be_nsuffix[ 0 ];
00498 
00499        op->o_dn = op->o_bd->be_rootdn;
00500        op->o_ndn = op->o_bd->be_rootndn;
00501 
00502        op->ors_scope = LDAP_SCOPE_SUBTREE;
00503        op->ors_tlimit = SLAP_NO_LIMIT;
00504        op->ors_slimit = SLAP_NO_LIMIT;
00505        op->ors_attrs = slap_anlist_no_attrs;
00506 
00507        op->ors_filterstr.bv_len = STRLENOF( "(!(=*))" ) + ad_rdnValue->ad_cname.bv_len;
00508        op->ors_filterstr.bv_val = op->o_tmpalloc( op->ors_filterstr.bv_len + 1, op->o_tmpmemctx );
00509        snprintf( op->ors_filterstr.bv_val, op->ors_filterstr.bv_len + 1,
00510               "(!(%s=*))", ad_rdnValue->ad_cname.bv_val );
00511 
00512        op->ors_filter = str2filter_x( op, op->ors_filterstr.bv_val );
00513        if ( op->ors_filter == NULL ) {
00514               rs.sr_err = LDAP_OTHER;
00515               goto done_search;
00516        }
00517        
00518        op->o_callback = &sc;
00519        sc.sc_response = rdnval_repair_cb;
00520        sc.sc_private = &rcb;
00521        rcb.bd = &db;
00522        db = *be;
00523        db.bd_info = (BackendInfo *)on;
00524 
00525        (void)op->o_bd->bd_info->bi_op_search( op, &rs );
00526 
00527        op->o_tag = LDAP_REQ_MODIFY;
00528        sc.sc_response = slap_null_cb;
00529        sc.sc_private = NULL;
00530        memset( &op->oq_modify, 0, sizeof( req_modify_s ) );
00531 
00532        for ( rmod = rcb.mods; rmod != NULL; ) {
00533               rdnval_mod_t *rnext;
00534 
00535               Modifications *mod;
00536               SlapReply rs2 = { REP_RESULT };
00537 
00538               mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
00539               mod->sml_flags = SLAP_MOD_INTERNAL;
00540               mod->sml_op = LDAP_MOD_REPLACE;
00541               mod->sml_desc = ad_rdnValue;
00542               mod->sml_type = ad_rdnValue->ad_cname;
00543               mod->sml_values = rmod->vals;
00544               mod->sml_nvalues = rmod->nvals;
00545               mod->sml_numvals = rmod->numvals;
00546               mod->sml_next = NULL;
00547 
00548               op->o_req_dn = rmod->ndn;
00549               op->o_req_ndn = rmod->ndn;
00550 
00551               op->orm_modlist = mod;
00552 
00553               op->o_bd->be_modify( op, &rs2 );
00554 
00555               slap_mods_free( op->orm_modlist, 1 );
00556               if ( rs2.sr_err == LDAP_SUCCESS ) {
00557                      Debug( LDAP_DEBUG_TRACE, "%s: rdnval_repair: entry DN=\"%s\" repaired\n",
00558                             op->o_log_prefix, rmod->ndn.bv_val, 0 );
00559                      nrepaired++;
00560 
00561               } else {
00562                      Debug( LDAP_DEBUG_ANY, "%s: rdnval_repair: entry DN=\"%s\" repair failed (%d)\n",
00563                             op->o_log_prefix, rmod->ndn.bv_val, rs2.sr_err );
00564               }
00565 
00566               rnext = rmod->next;
00567               op->o_tmpfree( rmod, op->o_tmpmemctx );
00568               rmod = rnext;
00569        }
00570 
00571 done_search:;
00572        op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
00573        filter_free_x( op, op->ors_filter, 1 );
00574 
00575        Log1( LDAP_DEBUG_STATS, LDAP_LEVEL_INFO,
00576               "rdnval: repaired=%d\n", nrepaired );
00577 
00578        return 0;
00579 }
00580 
00581 /* search all entries without parentUUID; "repair" them */
00582 static int
00583 rdnval_db_open(
00584        BackendDB     *be,
00585        ConfigReply   *cr )
00586 {
00587        if ( SLAP_SINGLE_SHADOW( be ) ) {
00588               Log1( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
00589                      "rdnval incompatible with shadow database \"%s\".\n",
00590                      be->be_suffix[ 0 ].bv_val );
00591               return 1;
00592        }
00593 
00594        return rdnval_repair( be );
00595 }
00596 
00597 static struct {
00598        char   *desc;
00599        AttributeDescription **adp;
00600 } as[] = {
00601        { "( 1.3.6.1.4.1.4203.666.1.58 "
00602               "NAME 'rdnValue' "
00603               "DESC 'the value of the naming attributes' "
00604               "SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' "
00605               "EQUALITY caseIgnoreMatch "
00606               "USAGE dSAOperation "
00607               "NO-USER-MODIFICATION " 
00608               ")",
00609               &ad_rdnValue },
00610        { NULL }
00611 };
00612 
00613 int
00614 rdnval_initialize(void)
00615 {
00616        int code, i;
00617 
00618        for ( i = 0; as[ i ].desc != NULL; i++ ) {
00619               code = register_at( as[ i ].desc, as[ i ].adp, 0 );
00620               if ( code ) {
00621                      Debug( LDAP_DEBUG_ANY,
00622                             "rdnval_initialize: register_at #%d failed\n",
00623                             i, 0, 0 );
00624                      return code;
00625               }
00626 
00627               /* Allow Manager to set these as needed */
00628               if ( is_at_no_user_mod( (*as[ i ].adp)->ad_type ) ) {
00629                      (*as[ i ].adp)->ad_type->sat_flags |=
00630                             SLAP_AT_MANAGEABLE;
00631               }
00632        }
00633 
00634        syn_IA5String = syn_find( "1.3.6.1.4.1.1466.115.121.1.26" );
00635        if ( syn_IA5String == NULL ) {
00636               Debug( LDAP_DEBUG_ANY,
00637                      "rdnval_initialize: unable to find syntax '1.3.6.1.4.1.1466.115.121.1.26' (IA5String)\n",
00638                      0, 0, 0 );
00639               return LDAP_OTHER;
00640        }
00641 
00642        rdnval.on_bi.bi_type = "rdnval";
00643 
00644        rdnval.on_bi.bi_op_add = rdnval_op_add;
00645        rdnval.on_bi.bi_op_modrdn = rdnval_op_rename;
00646 
00647        rdnval.on_bi.bi_db_init = rdnval_db_init;
00648        rdnval.on_bi.bi_db_open = rdnval_db_open;
00649 
00650        return overlay_register( &rdnval );
00651 }
00652 
00653 #if SLAPD_OVER_RDNVAL == SLAPD_MOD_DYNAMIC
00654 int
00655 init_module( int argc, char *argv[] )
00656 {
00657        return rdnval_initialize();
00658 }
00659 #endif /* SLAPD_OVER_RDNVAL == SLAPD_MOD_DYNAMIC */
00660 
00661 #endif /* SLAPD_OVER_RDNVAL */