]> git.sur5r.net Git - openldap/blob - servers/slapd/add.c
c9bb697f978252723ed71c14ad0204acf7279658
[openldap] / servers / slapd / add.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1995 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 #include "portable.h"
19
20 #include <stdio.h>
21 #include <ac/string.h>
22 #include <ac/time.h>
23 #include <ac/socket.h>
24
25 #include "ldap_pvt.h"
26 #include "slap.h"
27 #include "slapi.h"
28
29 int
30 do_add( Connection *conn, Operation *op )
31 {
32         BerElement      *ber = op->o_ber;
33         char            *last;
34         struct berval dn = { 0, NULL };
35         ber_len_t       len;
36         ber_tag_t       tag;
37         Entry           *e;
38         Backend         *be;
39         Modifications   *modlist = NULL;
40         Modifications   **modtail = &modlist;
41         Modifications   tmp, *mod;
42         const char *text;
43         LDAPRDN         *rdn = NULL;
44         int             cnt;
45         int                     rc = LDAP_SUCCESS;
46         int     manageDSAit;
47
48         Slapi_PBlock *pb = op->o_pb;
49
50 #ifdef NEW_LOGGING
51         LDAP_LOG( OPERATION, ENTRY, "do_add: conn %d enter\n", conn->c_connid,0,0 );
52 #else
53         Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
54 #endif
55         /*
56          * Parse the add request.  It looks like this:
57          *
58          *      AddRequest := [APPLICATION 14] SEQUENCE {
59          *              name    DistinguishedName,
60          *              attrs   SEQUENCE OF SEQUENCE {
61          *                      type    AttributeType,
62          *                      values  SET OF AttributeValue
63          *              }
64          *      }
65          */
66
67         /* get the name */
68         if ( ber_scanf( ber, "{m", /*}*/ &dn ) == LBER_ERROR ) {
69 #ifdef NEW_LOGGING
70                 LDAP_LOG( OPERATION, ERR, 
71                         "do_add: conn %d ber_scanf failed\n", conn->c_connid,0,0 );
72 #else
73                 Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
74 #endif
75                 send_ldap_disconnect( conn, op,
76                         LDAP_PROTOCOL_ERROR, "decoding error" );
77                 return -1;
78         }
79
80         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
81
82         rc = dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname );
83
84         if( rc != LDAP_SUCCESS ) {
85 #ifdef NEW_LOGGING
86                 LDAP_LOG( OPERATION, ERR, 
87                         "do_add: conn %d invalid dn (%s)\n", conn->c_connid, dn.bv_val, 0 );
88 #else
89                 Debug( LDAP_DEBUG_ANY, "do_add: invalid dn (%s)\n", dn.bv_val, 0, 0 );
90 #endif
91                 send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
92                             "invalid DN", NULL, NULL );
93                 goto done;
94         }
95
96 #ifdef NEW_LOGGING
97         LDAP_LOG( OPERATION, ARGS, 
98                 "do_add: conn %d  dn (%s)\n", conn->c_connid, e->e_dn, 0 );
99 #else
100         Debug( LDAP_DEBUG_ARGS, "do_add: dn (%s)\n", e->e_dn, 0, 0 );
101 #endif
102
103         /* get the attrs */
104         for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
105             tag = ber_next_element( ber, &len, last ) )
106         {
107                 Modifications *mod;
108                 ber_tag_t rtag;
109
110                 rtag = ber_scanf( ber, "{m{W}}", &tmp.sml_type, &tmp.sml_bvalues );
111
112                 if ( rtag == LBER_ERROR ) {
113 #ifdef NEW_LOGGING
114                         LDAP_LOG( OPERATION, ERR, 
115                                    "do_add: conn %d      decoding error \n", conn->c_connid, 0, 0 );
116 #else
117                         Debug( LDAP_DEBUG_ANY, "do_add: decoding error\n", 0, 0, 0 );
118 #endif
119                         send_ldap_disconnect( conn, op,
120                                 LDAP_PROTOCOL_ERROR, "decoding error" );
121                         rc = -1;
122                         goto done;
123                 }
124
125                 if ( tmp.sml_bvalues == NULL ) {
126 #ifdef NEW_LOGGING
127                         LDAP_LOG( OPERATION, INFO, 
128                                 "do_add: conn %d         no values for type %s\n",
129                                 conn->c_connid, tmp.sml_type.bv_val, 0 );
130 #else
131                         Debug( LDAP_DEBUG_ANY, "no values for type %s\n",
132                                 tmp.sml_type.bv_val, 0, 0 );
133 #endif
134                         send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
135                                 NULL, "no values for attribute type", NULL, NULL );
136                         goto done;
137                 }
138                 mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
139                 
140                 mod->sml_op = LDAP_MOD_ADD;
141                 mod->sml_next = NULL;
142                 mod->sml_desc = NULL;
143                 mod->sml_type = tmp.sml_type;
144                 mod->sml_bvalues = tmp.sml_bvalues;
145
146                 *modtail = mod;
147                 modtail = &mod->sml_next;
148         }
149
150         if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
151 #ifdef NEW_LOGGING
152                 LDAP_LOG( OPERATION, ERR, 
153                         "do_add: conn %d ber_scanf failed\n", conn->c_connid, 0, 0 );
154 #else
155                 Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
156 #endif
157                 send_ldap_disconnect( conn, op,
158                         LDAP_PROTOCOL_ERROR, "decoding error" );
159                 rc = -1;
160                 goto done;
161         }
162
163         if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
164 #ifdef NEW_LOGGING
165                 LDAP_LOG( OPERATION, INFO, 
166                         "do_add: conn %d get_ctrls failed\n", conn->c_connid, 0, 0 );
167 #else
168                 Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
169 #endif
170                 goto done;
171         } 
172
173         if ( modlist == NULL ) {
174                 send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
175                         NULL, "no attributes provided", NULL, NULL );
176                 goto done;
177         }
178
179         Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu ADD dn=\"%s\"\n",
180             op->o_connid, op->o_opid, e->e_dn, 0, 0 );
181
182         if( e->e_nname.bv_len == 0 ) {
183                 /* protocolError may be a more appropriate error */
184                 send_ldap_result( conn, op, rc = LDAP_ALREADY_EXISTS,
185                         NULL, "root DSE already exists",
186                         NULL, NULL );
187                 goto done;
188
189         } else if ( bvmatch( &e->e_nname, &global_schemandn ) ) {
190                 send_ldap_result( conn, op, rc = LDAP_ALREADY_EXISTS,
191                         NULL, "subschema subentry already exists",
192                         NULL, NULL );
193                 goto done;
194         }
195
196         /*
197          * is objectClass special?
198          */
199
200         /* look for objectClass attribute */
201         for ( mod = modlist; mod; mod = mod->sml_next ) {
202                 AttributeDescription    *mod_desc = NULL;
203
204                 rc = slap_bv2ad( &mod->sml_type, &mod_desc, &text );
205                 if ( rc != LDAP_SUCCESS ) {
206                         send_ldap_result( conn, op, rc,
207                                         NULL, text, NULL, NULL );
208                         goto done;
209                 }
210
211                 if ( mod_desc == slap_schema.si_ad_objectClass ) {
212                         break;
213                 }
214         }
215
216         if ( mod == NULL ) {
217                 send_ldap_result( conn, op, 
218                                 rc = LDAP_OBJECT_CLASS_VIOLATION,
219                                 NULL, "objectClass missing", 
220                                 NULL, NULL );
221                 goto done;
222         }
223
224         /* look for special objectClass */
225         for ( cnt = 0; mod->sml_bvalues[ cnt ].bv_val; cnt++ ) {
226                 ObjectClass     *oc;
227
228                 oc = oc_bvfind( &mod->sml_bvalues[ cnt ] );
229
230                 if ( oc == NULL ) {
231                         send_ldap_result( conn, op, 
232                                         rc = LDAP_OBJECT_CLASS_VIOLATION,
233                                         NULL, "undefined objectClass", 
234                                         NULL, NULL );
235                         goto done;
236                 }
237
238                 /* check for special objectClass */
239                 if ( oc == slap_schema.si_oc_alias ) {
240                         break;
241                 }
242
243                 if ( oc == slap_schema.si_oc_referral ) {
244                         break;
245                 }
246
247                 if ( oc == slap_schema.si_oc_extensibleObject ) {
248                         break;
249                 }
250         }
251
252         /*
253          * if not special
254          */
255         if ( mod->sml_bvalues[ cnt ].bv_val == NULL ) {
256
257                 /*
258                  * Get attribute type(s) and attribute value(s) of our rdn,
259                  */
260                 if ( ldap_bv2rdn( &e->e_name, &rdn, (char **)&text,
261                         LDAP_DN_FORMAT_LDAP ) )
262                 {
263                         send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX,
264                                 NULL, "unknown type(s) used in RDN",
265                                 NULL, NULL );
266                         goto done;
267                 }
268
269                 /* Check for RDN attrs in entry */
270                 for ( cnt = 0; rdn[ 0 ][ cnt ]; cnt++ ) {
271                         AttributeDescription    *desc = NULL;
272                         MatchingRule            *mr;
273                         int                     i;
274         
275                         rc = slap_bv2ad( &rdn[ 0 ][ cnt ]->la_attr, 
276                                         &desc, &text );
277         
278                         if ( rc != LDAP_SUCCESS ) {
279                                 send_ldap_result( conn, op, rc,
280                                                 NULL, text, NULL, NULL );
281                                 goto done;
282                         }
283         
284                         for (mod = modlist; mod; mod = mod->sml_next) {
285                                 AttributeDescription    *mod_desc = NULL;
286         
287                                 rc = slap_bv2ad( &mod->sml_type, 
288                                                 &mod_desc, &text );
289                                 if ( rc != LDAP_SUCCESS ) {
290                                         send_ldap_result( conn, op, rc,
291                                                         NULL, text, NULL, NULL );
292                                         goto done;
293                                 }
294         
295                                 if (mod_desc == desc) {
296                                         break;
297                                 }
298                         }
299         
300                         if (mod == NULL) {
301 #define BAILOUT
302 #ifdef BAILOUT
303                                 /* bail out */
304                                 send_ldap_result( conn, op, 
305                                                 rc = LDAP_NO_SUCH_ATTRIBUTE,
306                                                 NULL,
307                                                 "attribute in RDN not listed in entry", 
308                                                 NULL, NULL );
309                                 goto done;
310         
311 #else /* ! BAILOUT */
312                                 struct berval   bv;
313         
314                                 /* add attribute type and value to modlist */
315                                 mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
316                         
317                                 mod->sml_op = LDAP_MOD_ADD;
318                                 mod->sml_next = NULL;
319                                 mod->sml_desc = NULL;
320         
321                                 ber_dupbv( &mod->sml_type,
322                                                 &rdn[ 0 ][ cnt ]->la_attr );
323         
324                                 mod->sml_bvalues = NULL;
325                                 ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
326                                 ber_bvarray_add( &mod->sml_bvalues, &bv );
327         
328                                 *modtail = mod;
329                                 modtail = &mod->sml_next;
330                                 continue;
331 #endif /* ! BAILOUT */
332                         }
333         
334                         mr = desc->ad_type->sat_equality;
335                         if (mr == NULL || !mr->smr_match ) {
336                                 /* bail out */
337                                 send_ldap_result( conn, op, 
338                                                 rc = LDAP_INVALID_SYNTAX,
339                                                 NULL,
340                                                 "attribute in RDN lacks matching rule", 
341                                                 NULL, NULL );
342                                 goto done;
343                         }
344         
345                         for (i = 0; mod->sml_bvalues[ i ].bv_val; i++) {
346                                 int             match = 0;
347                                 
348                                 rc = value_match(&match, desc, mr,
349                                                 SLAP_MR_VALUE_SYNTAX_MATCH,
350                                                 &mod->sml_bvalues[ i ],
351                                                 &rdn[ 0 ][ cnt ]->la_value, &text);
352         
353                                 if ( rc != LDAP_SUCCESS ) {
354                                         send_ldap_result( conn, op, rc,
355                                                         NULL, text, NULL, NULL);
356                                         goto done;
357                                 }
358         
359                                 if (match == 0) {
360                                         break;
361                                 }
362                         }
363         
364                         /* not found? */
365                         if (mod->sml_bvalues[ i ].bv_val == NULL) {
366 #ifdef BAILOUT
367                                 /* bailout */
368                                 send_ldap_result( conn, op, 
369                                                 rc = LDAP_NO_SUCH_ATTRIBUTE,
370                                                 NULL,
371                                                 "value in RDN not listed in entry", 
372                                                 NULL, NULL );
373                                 goto done;
374         
375 #else /* ! BAILOUT */
376                                 struct berval   bv;
377         
378                                 /* add attribute type and value to modlist */
379                                 ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
380                                 ber_bvarray_add( &mod->sml_bvalues, &bv );
381                                 continue;
382 #endif /* ! BAILOUT */
383                         }
384                 }
385         }
386
387         manageDSAit = get_manageDSAit( op );
388
389         /*
390          * We could be serving multiple database backends.  Select the
391          * appropriate one, or send a referral to our "referral server"
392          * if we don't hold it.
393          */
394         be = select_backend( &e->e_nname, manageDSAit, 0 );
395         if ( be == NULL ) {
396                 BerVarray ref = referral_rewrite( default_referral,
397                         NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
398
399                 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
400                         NULL, NULL, ref ? ref : default_referral, NULL );
401
402                 if ( ref ) ber_bvarray_free( ref );
403                 goto done;
404         }
405
406         /* check restrictions */
407         rc = backend_check_restrictions( be, conn, op, NULL, &text ) ;
408         if( rc != LDAP_SUCCESS ) {
409                 send_ldap_result( conn, op, rc,
410                         NULL, text, NULL, NULL );
411                 goto done;
412         }
413
414         /* check for referrals */
415         rc = backend_check_referrals( be, conn, op, &e->e_name, &e->e_nname );
416         if ( rc != LDAP_SUCCESS ) {
417                 goto done;
418         }
419
420 #if defined( LDAP_SLAPI )
421         slapi_x_backend_set_pb( pb, be );
422         slapi_x_connection_set_pb( pb, conn );
423         slapi_x_operation_set_pb( pb, op );
424         slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
425         slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn.bv_val );
426         slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
427
428         rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_ADD_FN, pb );
429         if ( rc != 0 ) {
430                 /*
431                  * A preoperation plugin failure will abort the
432                  * entire operation.
433                  */
434 #ifdef NEW_LOGGING
435                 LDAP_LOG( OPERATION, INFO, "do_add: add preoperation plugin failed\n",
436                                 0, 0, 0);
437 #else
438                 Debug(LDAP_DEBUG_TRACE, "do_add: add preoperation plugin failed.\n",
439                                 0, 0, 0);
440                 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 )
441                         rc = LDAP_OTHER;
442                 goto done;
443 #endif
444         }
445 #endif /* defined( LDAP_SLAPI ) */
446
447         /*
448          * do the add if 1 && (2 || 3)
449          * 1) there is an add function implemented in this backend;
450          * 2) this backend is master for what it holds;
451          * 3) it's a replica and the dn supplied is the updatedn.
452          */
453         if ( be->be_add ) {
454                 /* do the update here */
455                 int repl_user = be_isupdate(be, &op->o_ndn );
456 #ifndef SLAPD_MULTIMASTER
457                 if ( !be->be_update_ndn.bv_len || repl_user )
458 #endif
459                 {
460                         int update = be->be_update_ndn.bv_len;
461                         char textbuf[SLAP_TEXT_BUFLEN];
462                         size_t textlen = sizeof textbuf;
463
464                         rc = slap_mods_check( modlist, update, &text,
465                                 textbuf, textlen );
466
467                         if( rc != LDAP_SUCCESS ) {
468                                 send_ldap_result( conn, op, rc,
469                                         NULL, text, NULL, NULL );
470                                 goto done;
471                         }
472
473                         if ( !repl_user ) {
474                                 for( modtail = &modlist;
475                                         *modtail != NULL;
476                                         modtail = &(*modtail)->sml_next )
477                                 {
478                                         assert( (*modtail)->sml_op == LDAP_MOD_ADD );
479                                         assert( (*modtail)->sml_desc != NULL );
480                                 }
481                                 rc = slap_mods_opattrs( be, op, modlist, modtail, &text,
482                                         textbuf, textlen );
483                                 if( rc != LDAP_SUCCESS ) {
484                                         send_ldap_result( conn, op, rc,
485                                                 NULL, text, NULL, NULL );
486                                         goto done;
487                                 }
488                         }
489
490                         rc = slap_mods2entry( modlist, &e, repl_user, &text,
491                                 textbuf, textlen );
492                         if( rc != LDAP_SUCCESS ) {
493                                 send_ldap_result( conn, op, rc,
494                                         NULL, text, NULL, NULL );
495                                 goto done;
496                         }
497
498                         if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
499 #ifdef SLAPD_MULTIMASTER
500                                 if ( !repl_user )
501 #endif
502                                 {
503                                         replog( be, op, &e->e_name, &e->e_nname, e );
504                                 }
505                                 be_entry_release_w( be, conn, op, e );
506                                 e = NULL;
507                         }
508
509 #ifndef SLAPD_MULTIMASTER
510                 } else {
511                         BerVarray defref = be->be_update_refs
512                                 ? be->be_update_refs : default_referral;
513                         BerVarray ref = referral_rewrite( defref,
514                                 NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
515
516                         send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
517                                 ref ? ref : defref, NULL );
518
519                         if ( ref ) ber_bvarray_free( ref );
520 #endif
521                 }
522         } else {
523 #ifdef NEW_LOGGING
524             LDAP_LOG( OPERATION, INFO, 
525                        "do_add: conn %d  no backend support\n", conn->c_connid, 0, 0 );
526 #else
527             Debug( LDAP_DEBUG_ARGS, "    do_add: no backend support\n", 0, 0, 0 );
528 #endif
529             send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
530                               NULL, "operation not supported within namingContext", NULL, NULL );
531         }
532
533 #if defined( LDAP_SLAPI )
534         /*
535          * Postoperation errors are silently ignored; the work has
536          * been done.
537          */
538         if ( doPluginFNs( be, SLAPI_PLUGIN_POST_ADD_FN, pb ) != 0) {
539 #ifdef NEW_LOGGING
540                 LDAP_LOG( OPERATION, INFO, "do_add: Add postoperation plugins failed\n",
541                                 0, 0, 0);
542 #else
543                 Debug(LDAP_DEBUG_TRACE, "do_add: Add postoperation plugins failed.\n",
544                                 0, 0, 0);
545 #endif
546         }
547 #endif /* defined( LDAP_SLAPI ) */
548
549 done:
550         if( modlist != NULL ) {
551                 slap_mods_free( modlist );
552         }
553         if( e != NULL ) {
554                 entry_free( e );
555         }
556
557         return rc;
558 }
559
560 int
561 slap_mods2entry(
562         Modifications *mods,
563         Entry **e,
564         int repl_user,
565         const char **text,
566         char *textbuf, size_t textlen )
567 {
568         Attribute **tail = &(*e)->e_attrs;
569         assert( *tail == NULL );
570
571         *text = textbuf;
572
573         for( ; mods != NULL; mods = mods->sml_next ) {
574                 Attribute *attr;
575
576                 assert( mods->sml_op == LDAP_MOD_ADD );
577                 assert( mods->sml_desc != NULL );
578
579                 attr = attr_find( (*e)->e_attrs, mods->sml_desc );
580
581                 if( attr != NULL ) {
582 #define SLURPD_FRIENDLY
583 #ifdef SLURPD_FRIENDLY
584                         ber_len_t i,j;
585
586                         if( !repl_user ) {
587                                 snprintf( textbuf, textlen,
588                                         "attribute '%s' provided more than once",
589                                         mods->sml_desc->ad_cname.bv_val );
590                                 return LDAP_TYPE_OR_VALUE_EXISTS;
591                         }
592
593                         for( i=0; attr->a_vals[i].bv_val; i++ ) {
594                                 /* count them */
595                         }
596                         for( j=0; mods->sml_bvalues[j].bv_val; j++ ) {
597                                 /* count them */
598                         }
599                         j++;    /* NULL */
600                         
601                         attr->a_vals = ch_realloc( attr->a_vals,
602                                 sizeof( struct berval ) * (i+j) );
603
604                         /* should check for duplicates */
605
606                         AC_MEMCPY( &attr->a_vals[i], mods->sml_bvalues,
607                                 sizeof( struct berval ) * j );
608
609                         /* trim the mods array */
610                         ch_free( mods->sml_bvalues );
611                         mods->sml_bvalues = NULL;
612
613                         continue;
614 #else
615                         snprintf( textbuf, textlen,
616                                 "attribute '%s' provided more than once",
617                                 mods->sml_desc->ad_cname.bv_val );
618                         return LDAP_TYPE_OR_VALUE_EXISTS;
619 #endif
620                 }
621
622                 if( mods->sml_bvalues[1].bv_val != NULL ) {
623                         /* check for duplicates */
624                         int             i, j;
625                         MatchingRule *mr = mods->sml_desc->ad_type->sat_equality;
626
627                         /* check if the values we're adding already exist */
628                         if( mr == NULL || !mr->smr_match ) {
629                                 for ( i = 0; mods->sml_bvalues[i].bv_val != NULL; i++ ) {
630                                         /* test asserted values against themselves */
631                                         for( j = 0; j < i; j++ ) {
632                                                 if ( bvmatch( &mods->sml_bvalues[i],
633                                                         &mods->sml_bvalues[j] ) ) {
634                                                         /* value exists already */
635                                                         snprintf( textbuf, textlen,
636                                                                 "%s: value #%d provided more than once",
637                                                                 mods->sml_desc->ad_cname.bv_val, j );
638                                                         return LDAP_TYPE_OR_VALUE_EXISTS;
639                                                 }
640                                         }
641                                 }
642
643                         } else {
644                                 int             rc;
645                                 const char      *text = NULL;
646                                 char            textbuf[ SLAP_TEXT_BUFLEN ]  = { '\0' };
647                                 
648                                 rc = modify_check_duplicates( mods->sml_desc, mr,
649                                                 NULL, mods->sml_bvalues, 0,
650                                                 &text, textbuf, sizeof( textbuf ) );
651
652                                 if ( rc != LDAP_SUCCESS ) {
653                                         return rc;
654                                 }
655                         }
656                 }
657
658                 attr = ch_calloc( 1, sizeof(Attribute) );
659
660                 /* move ad to attr structure */
661                 attr->a_desc = mods->sml_desc;
662                 mods->sml_desc = NULL;
663
664                 /* move values to attr structure */
665                 /*      should check for duplicates */
666                 attr->a_vals = mods->sml_bvalues;
667                 mods->sml_bvalues = NULL;
668
669                 *tail = attr;
670                 tail = &attr->a_next;
671         }
672
673         return LDAP_SUCCESS;
674 }
675