]> git.sur5r.net Git - openldap/blob - servers/slapd/back-meta/search.c
Add SLAP_MR_ORDERED_INDEX - support for inequality indexing. Currently
[openldap] / servers / slapd / back-meta / search.c
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1999-2004 The OpenLDAP Foundation.
5  * Portions Copyright 2001-2003 Pierangelo Masarati.
6  * Portions Copyright 1999-2003 Howard Chu.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in the file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 /* ACKNOWLEDGEMENTS:
18  * This work was initially developed by the Howard Chu for inclusion
19  * in OpenLDAP Software and subsequently enhanced by Pierangelo
20  * Masarati.
21  */
22
23 #include "portable.h"
24
25 #include <stdio.h>
26
27 #include <ac/socket.h>
28 #include <ac/string.h>
29 #include <ac/time.h>
30
31 #include "slap.h"
32 #include "../back-ldap/back-ldap.h"
33 #include "back-meta.h"
34 #undef ldap_debug       /* silence a warning in ldap-int.h */
35 #include "ldap_log.h"
36 #include "../../../libraries/libldap/ldap-int.h"
37
38 static int
39 meta_send_entry(
40                 Operation       *op,
41                 SlapReply       *rs,
42                 struct metaconn *lc,
43                 int             i,
44                 LDAPMessage     *e
45 );
46
47 int
48 meta_back_search( Operation *op, SlapReply *rs )
49 {
50         struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
51         struct metaconn *lc;
52         struct metasingleconn *lsc;
53         struct timeval  tv = { 0, 0 };
54         LDAPMessage     *res = NULL, *e;
55         int     rc = 0, *msgid, sres = LDAP_SUCCESS;
56         char *err = NULL;
57         struct berval match = BER_BVNULL, mmatch = BER_BVNULL;
58         BerVarray v2refs = NULL;
59                 
60         int i, last = 0, candidates = 0, initial_candidates = 0,
61                         candidate_match = 0;
62         dncookie dc;
63
64         int     is_scope = 0,
65                 is_filter = 0;
66
67         /*
68          * controls are set in ldap_back_dobind()
69          * 
70          * FIXME: in case of values return filter, we might want
71          * to map attrs and maybe rewrite value
72          */
73         lc = meta_back_getconn( op, rs, META_OP_ALLOW_MULTIPLE, 
74                         &op->o_req_ndn, NULL );
75         if ( !lc ) {
76                 send_ldap_result( op, rs );
77                 return -1;
78         }
79
80         if ( !meta_back_dobind( lc, op ) ) {
81                 rs->sr_err = LDAP_OTHER;
82                 send_ldap_result( op, rs );
83                 return -1;
84         }
85
86         /*
87          * Array of message id of each target
88          */
89         msgid = ch_calloc( sizeof( int ), li->ntargets );
90         if ( msgid == NULL ) {
91                 rs->sr_err = LDAP_OTHER;
92                 send_ldap_result( op, rs );
93                 return -1;
94         }
95         
96         dc.conn = op->o_conn;
97         dc.rs = rs;
98
99         /*
100          * Inits searches
101          */
102         for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
103                 struct berval   realbase = op->o_req_dn;
104                 int             realscope = op->ors_scope;
105                 ber_len_t       suffixlen = 0;
106                 struct berval   mbase = BER_BVNULL; 
107                 struct berval   mfilter = BER_BVNULL;
108                 char            **mapped_attrs = NULL;
109
110                 if ( lsc->candidate != META_CANDIDATE ) {
111                         msgid[ i ] = -1;
112                         continue;
113                 }
114
115                 /* should we check return values? */
116                 if ( op->ors_deref != -1 ) {
117                         ldap_set_option( lsc->ld, LDAP_OPT_DEREF,
118                                         ( void * )&op->ors_deref);
119                 }
120                 if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
121                         ldap_set_option( lsc->ld, LDAP_OPT_TIMELIMIT,
122                                         ( void * )&op->ors_tlimit);
123                 }
124                 if ( op->ors_slimit != SLAP_NO_LIMIT ) {
125                         ldap_set_option( lsc->ld, LDAP_OPT_SIZELIMIT,
126                                         ( void * )&op->ors_slimit);
127                 }
128
129                 dc.rwmap = &li->targets[ i ]->rwmap;
130
131                 /*
132                  * modifies the base according to the scope, if required
133                  */
134                 suffixlen = li->targets[ i ]->suffix.bv_len;
135                 if ( suffixlen > op->o_req_ndn.bv_len ) {
136                         switch ( op->ors_scope ) {
137                         case LDAP_SCOPE_SUBTREE:
138                                 /*
139                                  * make the target suffix the new base
140                                  * FIXME: this is very forgiving, because
141                                  * illegal bases may be turned into 
142                                  * the suffix of the target.
143                                  */
144                                 if ( dnIsSuffix( &li->targets[ i ]->suffix,
145                                                 &op->o_req_ndn ) ) {
146                                         realbase = li->targets[ i ]->suffix;
147                                         is_scope++;
148
149                                 } else {
150                                         /*
151                                          * this target is no longer candidate
152                                          */
153                                         msgid[ i ] = -1;
154                                         goto new_candidate;
155                                 }
156                                 break;
157
158                         case LDAP_SCOPE_ONELEVEL:
159                         {
160                                 struct berval   rdn = li->targets[ i ]->suffix;
161                                 rdn.bv_len -= op->o_req_ndn.bv_len + STRLENOF( "," );
162                                 if ( dnIsOneLevelRDN( &rdn )
163                                                 && dnIsSuffix( &li->targets[ i ]->suffix, &op->o_req_ndn ) )
164                                 {
165                                         /*
166                                          * if there is exactly one level,
167                                          * make the target suffix the new
168                                          * base, and make scope "base"
169                                          */
170                                         realbase = li->targets[ i ]->suffix;
171                                         realscope = LDAP_SCOPE_BASE;
172                                         is_scope++;
173                                         break;
174                                 } /* else continue with the next case */
175                         }
176
177                         case LDAP_SCOPE_BASE:
178                                 /*
179                                  * this target is no longer candidate
180                                  */
181                                 msgid[ i ] = -1;
182                                 goto new_candidate;
183                         }
184
185                 }
186
187                 /*
188                  * Rewrite the search base, if required
189                  */
190                 dc.ctx = "searchBase";
191                 switch ( ldap_back_dn_massage( &dc, &realbase, &mbase ) ) {
192                 default:
193                         break;
194
195                 case REWRITE_REGEXEC_UNWILLING:
196                         rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
197                         rs->sr_text = "Operation not allowed";
198                         send_ldap_result( op, rs );
199                         rc = -1;
200                         goto finish;
201
202                 case REWRITE_REGEXEC_ERR:
203 #if 0
204                         rs->sr_err = LDAP_OTHER;
205                         rs->sr_text = "Rewrite error";
206                         send_ldap_result( op, rs );
207                         rc = -1;
208                         goto finish;
209 #endif 
210
211                         /*
212                          * this target is no longer candidate
213                          */
214                         msgid[ i ] = -1;
215                         goto new_candidate;
216                 }
217
218                 /*
219                  * Maps filter
220                  */
221                 rc = ldap_back_filter_map_rewrite( &dc,
222                                 op->ors_filter,
223                                 &mfilter, BACKLDAP_MAP );
224                 switch ( rc ) {
225                 case LDAP_SUCCESS:
226                         is_filter++;
227                         break;
228
229                 case LDAP_COMPARE_FALSE:
230                         rc = 0;
231
232                 default:
233                         /*
234                          * this target is no longer candidate
235                          */
236                         msgid[ i ] = -1;
237                         goto new_candidate;
238                 }
239
240                 /*
241                  * Maps required attributes
242                  */
243                 rc = ldap_back_map_attrs( &li->targets[ i ]->rwmap.rwm_at,
244                                 op->ors_attrs, BACKLDAP_MAP,
245                                 &mapped_attrs );
246                 if ( rc != LDAP_SUCCESS ) {
247                         /*
248                          * this target is no longer candidate
249                          */
250                         msgid[ i ] = -1;
251                         goto new_candidate;
252                 }
253
254                 /*
255                  * Starts the search
256                  */
257                 msgid[ i ] = ldap_search( lsc->ld, mbase.bv_val, realscope,
258                                 mfilter.bv_val, mapped_attrs,
259                                 op->ors_attrsonly ); 
260                 if ( mapped_attrs ) {
261                         free( mapped_attrs );
262                         mapped_attrs = NULL;
263                 }
264                 if ( mfilter.bv_val != op->ors_filterstr.bv_val ) {
265                         free( mfilter.bv_val );
266                         mfilter.bv_val = NULL;
267                 }
268                 if ( mbase.bv_val != realbase.bv_val ) {
269                         free( mbase.bv_val );
270                         mbase.bv_val = NULL;
271                 }
272
273                 if ( msgid[ i ] == -1 ) {
274                         continue;
275                 }
276
277                 ++candidates;
278
279 new_candidate:;
280         }
281
282         initial_candidates = candidates;
283
284         /* We pull apart the ber result, stuff it into a slapd entry, and
285          * let send_search_entry stuff it back into ber format. Slow & ugly,
286          * but this is necessary for version matching, and for ACL processing.
287          */
288
289
290         /*
291          * In case there are no candidates, no cycle takes place...
292          *
293          * FIXME: we might use a queue, to balance the load 
294          * among the candidates
295          */
296         for ( rc = 0; candidates > 0; ) {
297                 int ab, gotit = 0;
298
299                 /* check for abandon */
300                 ab = op->o_abandon;
301
302                 for ( i = 0, lsc = lc->conns; !META_LAST(lsc); lsc++, i++ ) {
303                         if ( msgid[ i ] == -1 ) {
304                                 continue;
305                         }
306                         
307                         if ( ab ) {
308                                 ldap_abandon( lsc->ld, msgid[ i ] );
309                                 rc = 0;
310                                 break;
311                         }
312
313                         if ( op->ors_slimit > 0
314                                         && rs->sr_nentries == op->ors_slimit ) {
315                                 rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
316                                 rs->sr_v2ref = v2refs;
317                                 send_ldap_result( op, rs );
318                                 goto finish;
319                         }
320
321                         /*
322                          * FIXME: handle time limit as well?
323                          * Note that target servers are likely 
324                          * to handle it, so at some time we'll
325                          * get a LDAP_TIMELIMIT_EXCEEDED from
326                          * one of them ...
327                          */
328                         rc = ldap_result( lsc->ld, msgid[ i ],
329                                         0, &tv, &res );
330
331                         if ( rc == 0 ) {
332                                 /* timeout exceeded */
333
334                                 /* FIXME: res should not need to be freed */
335                                 assert( res == NULL );
336
337                                 continue;
338
339                         } else if ( rc == -1 ) {
340                                 /* something REALLY bad happened! */
341                                 ( void )meta_clear_unused_candidates( li,
342                                                 lc, -1, 0 );
343                                 rs->sr_err = LDAP_OTHER;
344                                 rs->sr_v2ref = v2refs;
345                                 send_ldap_result( op, rs );
346                                 
347                                 /* anything else needs be done? */
348
349                                 /* FIXME: res should not need to be freed */
350                                 assert( res == NULL );
351
352                                 goto finish;
353
354                         } else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
355                                 e = ldap_first_entry( lsc->ld, res );
356                                 meta_send_entry( op, rs, lc, i, e );
357
358                                 ldap_msgfree( res );
359                                 res = NULL;
360
361                                 /*
362                                  * If scope is BASE, we need to jump out
363                                  * as soon as one entry is found; if
364                                  * the target pool is properly crafted,
365                                  * this should correspond to the sole
366                                  * entry that has the base DN
367                                  */
368                                 if ( op->ors_scope == LDAP_SCOPE_BASE
369                                                 && rs->sr_nentries > 0 ) {
370                                         candidates = 0;
371                                         sres = LDAP_SUCCESS;
372                                         break;
373                                 }
374
375                                 gotit = 1;
376
377                         } else if ( rc == LDAP_RES_SEARCH_REFERENCE ) {
378                                 char            **references = NULL;
379                                 int             cnt;
380
381                                 /*
382                                  * FIXME: should we collect references
383                                  * and send them alltogether at the end?
384                                  */
385
386                                 rc = ldap_parse_reference( lsc->ld, res,
387                                                 &references, &rs->sr_ctrls, 1 );
388                                 res = NULL;
389
390                                 if ( rc != LDAP_SUCCESS ) {
391                                         continue;
392                                 }
393
394                                 if ( references == NULL ) {
395                                         continue;
396                                 }
397
398                                 for ( cnt = 0; references[ cnt ]; cnt++ )
399                                         /* NO OP */ ;
400                                 
401                                 rs->sr_ref = ch_calloc( cnt + 1, sizeof( struct berval ) );
402
403                                 for ( cnt = 0; references[ cnt ]; cnt++ ) {
404                                         rs->sr_ref[ cnt ].bv_val = references[ cnt ];
405                                         rs->sr_ref[ cnt ].bv_len = strlen( references[ cnt ] );
406                                 }
407
408                                 /* ignore return value by now */
409                                 ( void )send_search_reference( op, rs );
410
411                                 /* cleanup */
412                                 if ( references ) {
413                                         ldap_value_free( references );
414                                         ch_free( rs->sr_ref );
415                                         rs->sr_ref = NULL;
416                                 }
417
418                                 if ( rs->sr_ctrls ) {
419                                         ldap_controls_free( rs->sr_ctrls );
420                                         rs->sr_ctrls = NULL;
421                                 }
422
423                         } else {
424                                 rs->sr_err = ldap_result2error( lsc->ld,
425                                                 res, 1 );
426                                 res = NULL;
427
428                                 sres = slap_map_api2result( rs );
429                                 if ( err != NULL ) {
430                                         free( err );
431                                 }
432                                 ldap_get_option( lsc->ld,
433                                                 LDAP_OPT_ERROR_STRING, &err );
434                                 if ( match.bv_val != NULL ) {
435                                         free( match.bv_val );
436                                 }
437                                 ldap_get_option( lsc->ld,
438                                                 LDAP_OPT_MATCHED_DN, &match.bv_val );
439
440                                 Debug( LDAP_DEBUG_ANY,
441                                         "=>meta_back_search [%d] "
442                                         "match=\"%s\" err=\"%s\"\n",
443                                         i, match.bv_val, err ); 
444                                 candidate_match++;
445                                 last = i;
446                                 rc = 0;
447
448                                 /*
449                                  * When no candidates are left,
450                                  * the outer cycle finishes
451                                  */
452                                 msgid[ i ] = -1;
453                                 --candidates;
454                         }
455                 }
456
457                 if ( ab ) {
458                         goto finish;
459                 }
460
461                 if ( gotit == 0 ) {
462                         tv.tv_sec = 0;
463                         tv.tv_usec = 100000;
464                         ldap_pvt_thread_yield();
465                 } else {
466                         tv.tv_sec = 0;
467                         tv.tv_usec = 0;
468                 }
469         }
470
471         if ( rc == -1 ) {
472                 /*
473                  * FIXME: need a strategy to handle errors
474                  */
475                 rc = meta_back_op_result( lc, op, rs );
476                 goto finish;
477         }
478
479         /*
480          * Rewrite the matched portion of the search base, if required
481          * 
482          * FIXME: only the last one gets caught!
483          */
484         if ( candidate_match == initial_candidates
485                         && match.bv_val != NULL && *match.bv_val ) {
486                 dc.ctx = "matchedDN";
487                 dc.rwmap = &li->targets[ last ]->rwmap;
488
489                 if ( ldap_back_dn_massage( &dc, &match, &mmatch ) ) {
490                         mmatch.bv_val = NULL;
491                 }
492         }
493
494         /*
495          * In case we returned at least one entry, we return LDAP_SUCCESS
496          * otherwise, the latter error code we got
497          *
498          * FIXME: we should handle error codes and return the more 
499          * important/reasonable
500          */
501         if ( is_scope == 0 ) {
502                 sres = LDAP_NO_SUCH_OBJECT;
503         }
504
505         if ( sres == LDAP_SUCCESS && v2refs ) {
506                 sres = LDAP_REFERRAL;
507         }
508         rs->sr_err = sres;
509         rs->sr_matched = mmatch.bv_val;
510         rs->sr_v2ref = v2refs;
511         send_ldap_result( op, rs );
512         rs->sr_matched = NULL;
513         rs->sr_v2ref = NULL;
514
515
516 finish:;
517         if ( match.bv_val ) {
518                 if ( mmatch.bv_val != match.bv_val ) {
519                         free( mmatch.bv_val );
520                 }
521                 free( match.bv_val );
522         }
523         
524         if ( err ) {
525                 free( err );
526         }
527         
528         if ( msgid ) {
529                 ch_free( msgid );
530         }
531
532         return rc;
533 }
534
535 static int
536 meta_send_entry(
537                 Operation       *op,
538                 SlapReply       *rs,
539                 struct metaconn *lc,
540                 int             target,
541                 LDAPMessage     *e
542 )
543 {
544         struct metainfo         *li = ( struct metainfo * )op->o_bd->be_private;
545         struct berval           a, mapped;
546         Entry                   ent = {0};
547         BerElement              ber = *e->lm_ber;
548         Attribute               *attr, **attrp;
549         struct berval           *bv, bdn;
550         const char              *text;
551         dncookie                dc;
552
553         if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) {
554                 return LDAP_DECODING_ERROR;
555         }
556
557         /*
558          * Rewrite the dn of the result, if needed
559          */
560         dc.rwmap = &li->targets[ target ]->rwmap;
561         dc.conn = op->o_conn;
562         dc.rs = rs;
563         dc.ctx = "searchResult";
564
565         rs->sr_err = ldap_back_dn_massage( &dc, &bdn, &ent.e_name );
566         if ( rs->sr_err != LDAP_SUCCESS) {
567                 return rs->sr_err;
568         }
569
570         /*
571          * Note: this may fail if the target host(s) schema differs
572          * from the one known to the meta, and a DN with unknown
573          * attributes is returned.
574          * 
575          * FIXME: should we log anything, or delegate to dnNormalize?
576          */
577         if ( dnNormalize( 0, NULL, NULL, &ent.e_name, &ent.e_nname,
578                 &op->o_tmpmemctx ) != LDAP_SUCCESS )
579         {
580                 return LDAP_INVALID_DN_SYNTAX;
581         }
582
583         /*
584          * cache dn
585          */
586         if ( li->cache.ttl != META_DNCACHE_DISABLED ) {
587                 ( void )meta_dncache_update_entry( &li->cache,
588                                 &ent.e_nname, target );
589         }
590
591         attrp = &ent.e_attrs;
592
593         dc.ctx = "searchAttrDN";
594         while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
595                 int             last = 0;
596
597                 ldap_back_map( &li->targets[ target ]->rwmap.rwm_at, 
598                                 &a, &mapped, BACKLDAP_REMAP );
599                 if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) {
600                         continue;
601                 }
602                 attr = ( Attribute * )ch_malloc( sizeof( Attribute ) );
603                 if ( attr == NULL ) {
604                         continue;
605                 }
606                 attr->a_flags = 0;
607                 attr->a_next = 0;
608                 attr->a_desc = NULL;
609                 if ( slap_bv2ad( &mapped, &attr->a_desc, &text )
610                                 != LDAP_SUCCESS) {
611                         if ( slap_bv2undef_ad( &mapped, &attr->a_desc, &text ) 
612                                         != LDAP_SUCCESS) {
613                                 Debug( LDAP_DEBUG_ANY,
614                                                 "slap_bv2undef_ad(%s): "
615                                                 "%s\n%s", mapped.bv_val, text, "" );
616                                 ch_free( attr );
617                                 continue;
618                         }
619                 }
620
621                 /* no subschemaSubentry */
622                 if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry ) {
623
624                         /* 
625                          * We eat target's subschemaSubentry because
626                          * a search for this value is likely not
627                          * to resolve to the appropriate backend;
628                          * later, the local subschemaSubentry is
629                          * added.
630                          */
631                         ( void )ber_scanf( &ber, "x" /* [W] */ );
632
633                         ch_free(attr);
634                         continue;
635                 }
636
637                 if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR 
638                                 || attr->a_vals == NULL ) {
639                         attr->a_vals = &slap_dummy_bv;
640
641                 } else if ( attr->a_desc == slap_schema.si_ad_objectClass
642                                 || attr->a_desc == slap_schema.si_ad_structuralObjectClass ) {
643
644                         for ( last = 0; attr->a_vals[ last ].bv_val; ++last );
645
646                         for ( bv = attr->a_vals; bv->bv_val; bv++ ) {
647                                 ldap_back_map( &li->targets[ target ]->rwmap.rwm_oc,
648                                                 bv, &mapped, BACKLDAP_REMAP );
649                                 if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
650                                         free( bv->bv_val );
651                                         bv->bv_val = NULL;
652                                         if ( --last < 0 ) {
653                                                 break;
654                                         }
655                                         *bv = attr->a_vals[ last ];
656                                         attr->a_vals[ last ].bv_val = NULL;
657                                         bv--;
658
659                                 } else if ( mapped.bv_val != bv->bv_val ) {
660                                         free( bv->bv_val );
661                                         ber_dupbv( bv, &mapped );
662                                 }
663                         }
664                 /*
665                  * It is necessary to try to rewrite attributes with
666                  * dn syntax because they might be used in ACLs as
667                  * members of groups; since ACLs are applied to the
668                  * rewritten stuff, no dn-based subecj clause could
669                  * be used at the ldap backend side (see
670                  * http://www.OpenLDAP.org/faq/data/cache/452.html)
671                  * The problem can be overcome by moving the dn-based
672                  * ACLs to the target directory server, and letting
673                  * everything pass thru the ldap backend.
674                  */
675                 } else if ( attr->a_desc->ad_type->sat_syntax ==
676                                 slap_schema.si_syn_distinguishedName ) {
677                         ldap_dnattr_result_rewrite( &dc, attr->a_vals );
678                 }
679
680                 if ( last && attr->a_desc->ad_type->sat_equality &&
681                         attr->a_desc->ad_type->sat_equality->smr_normalize ) {
682                         int i;
683
684                         attr->a_nvals = ch_malloc((last + 1)*sizeof(struct berval));
685                         for ( i = 0; i<last; i++ ) {
686                                 attr->a_desc->ad_type->sat_equality->smr_normalize(
687                                         SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
688                                         attr->a_desc->ad_type->sat_syntax,
689                                         attr->a_desc->ad_type->sat_equality,
690                                         &attr->a_vals[i], &attr->a_nvals[i],
691                                         op->o_tmpmemctx );
692                         }
693                         attr->a_nvals[i].bv_val = NULL;
694                         attr->a_nvals[i].bv_len = 0;
695                 } else {
696                         attr->a_nvals = attr->a_vals;
697                 }
698
699                 *attrp = attr;
700                 attrp = &attr->a_next;
701         }
702         rs->sr_entry = &ent;
703         rs->sr_attrs = op->ors_attrs;
704         rs->sr_flags = 0;
705         send_search_entry( op, rs );
706         rs->sr_entry = NULL;
707         rs->sr_attrs = NULL;
708         while ( ent.e_attrs ) {
709                 attr = ent.e_attrs;
710                 ent.e_attrs = attr->a_next;
711                 if ( attr->a_vals != &slap_dummy_bv ) {
712                         ber_bvarray_free( attr->a_vals );
713                 }
714                 free( attr );
715         }
716         
717         if ( ent.e_dn && ent.e_dn != bdn.bv_val ) {
718                 free( ent.e_dn );
719         }
720         if ( ent.e_ndn ) {
721                 free( ent.e_ndn );
722         }
723
724         return LDAP_SUCCESS;
725 }
726
727