X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Fattr.c;h=2f6203e66f2934457c08f29d0576a41a783f189c;hb=22bf5188a91d300453c4077eaa88af6b399ce7e9;hp=0ccbc0e8625bb94a99c61e79aacfc4b2177f2c57;hpb=6fbd42a90a619a6ed7078f2debbdad839a28222d;p=openldap diff --git a/servers/slapd/back-bdb/attr.c b/servers/slapd/back-bdb/attr.c index 0ccbc0e862..2f6203e66f 100644 --- a/servers/slapd/back-bdb/attr.c +++ b/servers/slapd/back-bdb/attr.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2000-2008 The OpenLDAP Foundation. + * Copyright 2000-2012 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -215,7 +215,7 @@ bdb_attr_index_config( goto done; } - if( slap_ad_is_binary( ad ) ) { + if( ad == slap_schema.si_ad_entryDN || slap_ad_is_binary( ad ) ) { if (c_reply) { snprintf(c_reply->msg, sizeof(c_reply->msg), "index of attribute \"%s\" disallowed", attrs[i] ); @@ -319,15 +319,20 @@ bdb_attr_index_config( if( rc ) { if ( bdb->bi_flags & BDB_IS_OPEN ) { AttrInfo *b = bdb_attr_mask( bdb, ad ); - /* If we were editing this attr, reset it */ - b->ai_indexmask &= ~BDB_INDEX_DELETING; - /* If this is leftover from a previous add, commit it */ - if ( b->ai_newmask ) - b->ai_indexmask = b->ai_newmask; - b->ai_newmask = a->ai_newmask; - ch_free( a ); - rc = 0; - continue; + /* If there is already an index defined for this attribute + * it must be replaced. Otherwise we end up with multiple + * olcIndex values for the same attribute */ + if ( b->ai_indexmask & BDB_INDEX_DELETING ) { + /* If we were editing this attr, reset it */ + b->ai_indexmask &= ~BDB_INDEX_DELETING; + /* If this is leftover from a previous add, commit it */ + if ( b->ai_newmask ) + b->ai_indexmask = b->ai_newmask; + b->ai_newmask = a->ai_newmask; + ch_free( a ); + rc = 0; + continue; + } } if (c_reply) { snprintf(c_reply->msg, sizeof(c_reply->msg),