]> git.sur5r.net Git - openldap/blob - clients/tools/ldapsearch.c
0476b198f8ab5f0bba4dc415e54d2fd53203d0be
[openldap] / clients / tools / ldapsearch.c
1 #include "portable.h"
2
3 #include <stdio.h>
4
5 #include <ac/stdlib.h>
6
7 #include <ac/ctype.h>
8 #include <ac/signal.h>
9 #include <ac/string.h>
10 #include <ac/unistd.h>
11
12 #include <ldap.h>
13
14 #include "ldif.h"
15 #include "ldap_defaults.h"
16
17 #define DEFSEP          "="
18
19 static void
20 usage( char *s )
21 {
22         fprintf( stderr,
23 "usage: %s [options] filter [attributes...]\nwhere:\n"
24 "       filter\tRFC-1558 compliant LDAP search filter\n"
25 "       attributes\twhitespace-separated list of attributes to retrieve\n"
26 "\t\t1.1                -- no attributes\n"
27 "\t\t*            -- all user attributes\n"
28 "\t\t+            -- all operational attributes\n"
29 "\t\tempty list -- all non-operational attributes\n"
30 "options:\n"
31 "       -n\t\tshow what would be done but don't actually search\n"
32 "       -v\t\trun in verbose mode (diagnostics to standard output)\n"
33 "       -t\t\twrite binary values to files in TMPDIR\n"
34 "       -tt\t\twrite all values to files in TMPDIR\n"
35 "       -T path\twrite files to directory specified by path (default: \"/tmp\")\n"
36 "       -V prefix\tURL prefix for files (default: \"file://tmp/\"\n"
37 "       -u\t\tinclude User Friendly entry names in the output\n"
38 "       -A\t\tretrieve attribute names only (no values)\n"
39 "       -B\t\tdo not suppress printing of binary values\n"
40 "       -F sep\tprint `sep' instead of `=' between attribute names and values\n"
41 "       -L\t\tprint entries in LDIF format (implies -B)\n"
42 "       -LL\t\tprint entries in LDIF format without comments\n"
43 "       -LLL\t\tprint entries in LDIF format without comments and version\n"
44 "       -M\t\tenable Manage DSA IT control (-MM to make critical)\n"
45 "       -R\t\tdo not automatically follow referrals\n"
46 "       -S attr\tsort the results by attribute `attr'\n"
47 "       -d level\tset LDAP debugging level to `level'\n"
48 "       -f file\tperform sequence of searches listed in `file'\n"
49 "       -b basedn\tbase dn for search\n"
50 "       -s scope\tone of base, one, or sub (search scope)\n"
51 "       -a deref\tone of never, always, search, or find (alias dereferencing)\n"
52 "       -l limit\ttime limit (in seconds) for search\n"
53 "       -z limit\tsize limit (in entries) for search\n"
54 "       -D binddn\tbind dn\n"
55 "       -w passwd\tbind passwd (for simple authentication)\n"
56 "       -W\t\tprompt for bind passwd\n"
57 #ifdef HAVE_KERBEROS
58 "       -k\t\tuse Kerberos instead of Simple Password authentication\n"
59 #endif
60 "       -h host\tldap server\n"
61 "       -p port\tport on ldap server\n"
62 "       -P version\tprocotol version (2 or 3)\n"
63 ,               s );
64
65         exit( EXIT_FAILURE );
66 }
67
68 static void print_entry LDAP_P((
69         LDAP    *ld,
70         LDAPMessage     *entry,
71         int             attrsonly));
72
73 static int write_ldif LDAP_P((
74         int type,
75         char *name,
76         char *value,
77         ber_len_t vallen ));
78
79 static int dosearch LDAP_P((
80         LDAP    *ld,
81         char    *base,
82         int             scope,
83         char    **attrs,
84         int             attrsonly,
85         char    *filtpatt,
86         char    *value));
87
88 #define TMPDIR "/tmp"
89 #define URLPRE "file:/tmp/"
90
91 static char *tmpdir = NULL;
92 static char *urlpre = NULL;
93
94 static char     *binddn = NULL;
95 static char     *passwd = NULL;
96 static char     *base = NULL;
97 static char     *ldaphost = NULL;
98 static int      ldapport = 0;
99 static char     *sep = DEFSEP;
100 static char     *sortattr = NULL;
101 static int      skipsortattr = 0;
102 static int      verbose, not, includeufn, binary, vals2tmp, ldif;
103
104 int
105 main( int argc, char **argv )
106 {
107         char            *infile, *filtpattern, **attrs, line[ BUFSIZ ];
108         FILE            *fp;
109         int                     rc, i, first, scope, deref, attrsonly, manageDSAit;
110         int                     referrals, timelimit, sizelimit, debug;
111         int             authmethod, version, want_bindpw;
112         LDAP            *ld;
113
114         infile = NULL;
115         debug = verbose = binary = not = vals2tmp =
116                 attrsonly = manageDSAit = ldif = want_bindpw = 0;
117
118         deref = referrals = sizelimit = timelimit = version = -1;
119
120         scope = LDAP_SCOPE_SUBTREE;
121         authmethod = LDAP_AUTH_SIMPLE;
122
123         while (( i = getopt( argc, argv,
124                 "WKknuvtMRABLD:s:f:h:b:d:P:p:F:a:w:l:z:S:T:V:")) != EOF )
125         {
126         switch( i ) {
127         case 'n':       /* do Not do any searches */
128                 ++not;
129                 break;
130         case 'v':       /* verbose mode */
131                 ++verbose;
132                 break;
133         case 'd':
134                 debug |= atoi( optarg );
135                 break;
136         case 'k':       /* use kerberos bind */
137 #ifdef HAVE_KERBEROS
138                 authmethod = LDAP_AUTH_KRBV4;
139 #else
140                 fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
141 #endif
142                 break;
143         case 'K':       /* use kerberos bind, 1st part only */
144 #ifdef HAVE_KERBEROS
145                 authmethod = LDAP_AUTH_KRBV41;
146 #else
147                 fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
148 #endif
149                 break;
150         case 'u':       /* include UFN */
151                 ++includeufn;
152                 break;
153         case 't':       /* write attribute values to /tmp files */
154                 ++vals2tmp;
155                 break;
156         case 'M':
157                 /* enable Manage DSA IT */
158                 manageDSAit++;
159                 break;
160         case 'R':       /* don't automatically chase referrals */
161                 referrals = (int) LDAP_OPT_OFF;
162                 break;
163         case 'A':       /* retrieve attribute names only -- no values */
164                 ++attrsonly;
165                 break;
166         case 'L':       /* print entries in LDIF format */
167                 ++ldif;
168                 /* fall through -- always allow binary when outputting LDIF */
169         case 'B':       /* allow binary values to be printed */
170                 ++binary;
171                 break;
172         case 's':       /* search scope */
173                 if ( strcasecmp( optarg, "base" ) == 0 ) {
174                 scope = LDAP_SCOPE_BASE;
175                 } else if ( strcasecmp( optarg, "one" ) == 0 ) {
176                 scope = LDAP_SCOPE_ONELEVEL;
177                 } else if ( strcasecmp( optarg, "sub" ) == 0 ) {
178                 scope = LDAP_SCOPE_SUBTREE;
179                 } else {
180                 fprintf( stderr, "scope should be base, one, or sub\n" );
181                 usage( argv[ 0 ] );
182                 }
183                 break;
184
185         case 'a':       /* set alias deref option */
186                 if ( strcasecmp( optarg, "never" ) == 0 ) {
187                 deref = LDAP_DEREF_NEVER;
188                 } else if ( strcasecmp( optarg, "search" ) == 0 ) {
189                 deref = LDAP_DEREF_SEARCHING;
190                 } else if ( strcasecmp( optarg, "find" ) == 0 ) {
191                 deref = LDAP_DEREF_FINDING;
192                 } else if ( strcasecmp( optarg, "always" ) == 0 ) {
193                 deref = LDAP_DEREF_ALWAYS;
194                 } else {
195                 fprintf( stderr, "alias deref should be never, search, find, or always\n" );
196                 usage( argv[ 0 ] );
197                 }
198                 break;
199                 
200         case 'T':       /* field separator */
201                 if( tmpdir ) free( tmpdir );
202                 tmpdir = strdup( optarg );
203                 break;
204         case 'V':       /* field separator */
205                 if( urlpre ) free( urlpre );
206                 urlpre = strdup( optarg );
207                 break;
208         case 'F':       /* field separator */
209                 sep = strdup( optarg );
210                 break;
211         case 'f':       /* input file */
212                 infile = strdup( optarg );
213                 break;
214         case 'h':       /* ldap host */
215                 ldaphost = strdup( optarg );
216                 break;
217         case 'b':       /* searchbase */
218                 base = strdup( optarg );
219                 break;
220         case 'D':       /* bind DN */
221                 binddn = strdup( optarg );
222                 break;
223         case 'p':       /* ldap port */
224                 ldapport = atoi( optarg );
225                 break;
226         case 'w':       /* bind password */
227                 passwd = strdup( optarg );
228                 {
229                         char* p;
230
231                         for( p = optarg; *p == '\0'; p++ ) {
232                                 *p = '*';
233                         }
234                 }
235                 break;
236         case 'l':       /* time limit */
237                 timelimit = atoi( optarg );
238                 break;
239         case 'z':       /* size limit */
240                 sizelimit = atoi( optarg );
241                 break;
242         case 'S':       /* sort attribute */
243                 sortattr = strdup( optarg );
244                 break;
245         case 'W':
246                 want_bindpw++;
247                 break;
248         case 'P':
249                 switch( atoi( optarg ) )
250                 {
251                 case 2:
252                         version = LDAP_VERSION2;
253                         break;
254                 case 3:
255                         version = LDAP_VERSION3;
256                         break;
257                 default:
258                         fprintf( stderr, "protocol version should be 2 or 3\n" );
259                         usage( argv[0] );
260                 }
261                 break;
262         default:
263                 usage( argv[0] );
264         }
265         }
266
267         if ( argc - optind < 1 ) {
268                 usage( argv[ 0 ] );
269         }
270
271         filtpattern = strdup( argv[ optind ] );
272
273         if ( argv[ optind + 1 ] == NULL ) {
274                 attrs = NULL;
275         } else if ( sortattr == NULL || *sortattr == '\0' ) {
276                 attrs = &argv[ optind + 1 ];
277         } else {
278                 for ( i = optind + 1; i < argc; i++ ) {
279                         if ( strcasecmp( argv[ i ], sortattr ) == 0 ) {
280                                 break;
281                         }
282                 }
283                 if ( i == argc ) {
284                         skipsortattr = 1;
285                         argv[ optind ] = sortattr;
286                 } else {
287                         optind++;
288                 }
289                 attrs = &argv[ optind ];
290         }
291
292         if ( infile != NULL ) {
293                 if ( infile[0] == '-' && infile[1] == '\0' ) {
294                         fp = stdin;
295                 } else if (( fp = fopen( infile, "r" )) == NULL ) {
296                         perror( infile );
297                         return EXIT_FAILURE;
298                 }
299         }
300
301         if( tmpdir == NULL
302                 && (tmpdir = getenv("TMPDIR")) == NULL
303                 && (tmpdir = getenv("TMP")) == NULL
304                 && (tmpdir = getenv("TEMP")) == NULL )
305         {
306                 tmpdir = "/tmp";
307         }
308
309         if( urlpre == NULL ) {
310                 urlpre = malloc( sizeof("file:///") + strlen(tmpdir) );
311
312                 if( urlpre == NULL ) {
313                         perror( "malloc" );
314                         return EXIT_FAILURE;
315                 }
316
317                 sprintf( urlpre, "file:///%s/",
318                         tmpdir[0] == '/' ? &tmpdir[1] : tmpdir );
319
320                 /* urlpre should be URLized.... */
321         }
322
323         if ( debug ) {
324                 if( ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug ) != LBER_OPT_SUCCESS ) {
325                         fprintf( stderr, "Could not set LBER_OPT_DEBUG_LEVEL %d\n", debug );
326                 }
327                 if( ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug ) != LDAP_OPT_SUCCESS ) {
328                         fprintf( stderr, "Could not set LDAP_OPT_DEBUG_LEVEL %d\n", debug );
329                 }
330                 ldif_debug = debug;
331         }
332
333 #ifdef SIGPIPE
334         (void) SIGNAL( SIGPIPE, SIG_IGN );
335 #endif
336
337         if ( verbose ) {
338                 fprintf( stderr, "ldap_init( %s, %d )\n",
339                         (ldaphost != NULL) ? ldaphost : "<DEFAULT>",
340                         ldapport );
341         }
342
343         if (( ld = ldap_init( ldaphost, ldapport )) == NULL ) {
344                 perror( "ldap_init" );
345                 return( EXIT_FAILURE );
346         }
347
348         if (deref != -1 &&
349                 ldap_set_option( ld, LDAP_OPT_DEREF, (void *) &deref ) != LDAP_OPT_SUCCESS )
350         {
351                 fprintf( stderr, "Could not set LDAP_OPT_DEREF %d\n", deref );
352         }
353         if (timelimit != -1 &&
354                 ldap_set_option( ld, LDAP_OPT_TIMELIMIT, (void *) &timelimit ) != LDAP_OPT_SUCCESS )
355         {
356                 fprintf( stderr, "Could not set LDAP_OPT_TIMELIMIT %d\n", timelimit );
357         }
358         if (sizelimit != -1 &&
359                 ldap_set_option( ld, LDAP_OPT_SIZELIMIT, (void *) &sizelimit ) != LDAP_OPT_SUCCESS )
360         {
361                 fprintf( stderr, "Could not set LDAP_OPT_SIZELIMIT %d\n", sizelimit );
362         }
363         if (referrals != -1 &&
364                 ldap_set_option( ld, LDAP_OPT_REFERRALS,
365                                  (referrals ? LDAP_OPT_ON : LDAP_OPT_OFF) ) != LDAP_OPT_SUCCESS )
366         {
367                 fprintf( stderr, "Could not set LDAP_OPT_REFERRALS %s\n",
368                         referrals ? "on" : "off" );
369         }
370
371         if (version != -1 &&
372                 ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != LDAP_OPT_SUCCESS )
373         {
374                 fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n", version );
375         }
376
377         if (want_bindpw) {
378                 passwd = getpass("Enter LDAP Password: ");
379         }
380
381         if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
382                 ldap_perror( ld, "ldap_bind" );
383                 return( EXIT_FAILURE );
384         }
385
386         if ( manageDSAit ) {
387                 int err;
388                 LDAPControl c;
389                 LDAPControl *ctrls[2];
390                 ctrls[0] = &c;
391                 ctrls[1] = NULL;
392
393                 c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
394                 c.ldctl_value.bv_val = NULL;
395                 c.ldctl_value.bv_len = 0;
396                 c.ldctl_iscritical = manageDSAit > 1;
397
398                 err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, &ctrls );
399
400                 if( err != LDAP_OPT_SUCCESS ) {
401                         fprintf( stderr, "Could not set Manage DSA IT Control\n" );
402                         if( c.ldctl_iscritical ) {
403                                 exit( EXIT_FAILURE );
404                         }
405                 }
406         }
407
408         if ( verbose ) {
409                 fprintf( stderr, "filter%s: %s\nreturning: ",
410                         infile != NULL ? " pattern" : "",
411                         filtpattern );
412
413                 if ( attrs == NULL ) {
414                         printf( "ALL" );
415                 } else {
416                         for ( i = 0; attrs[ i ] != NULL; ++i ) {
417                                 fprintf( stderr, "%s ", attrs[ i ] );
418                         }
419                 }
420                 fprintf( stderr, "\n" );
421         }
422
423         if ( ldif ) {
424                 if (ldif < 3 ) {
425                         /* TEMPORARILY put the version in a comment many tools cannot yet a version attribute  */
426                         printf( "version: 1\n\n");
427                 }
428
429                 if (ldif < 2 ) {
430                         printf( "#\n# filter%s: %s\n# returning: ",
431                                 infile != NULL ? " pattern" : "",
432                                 filtpattern );
433
434                         if ( attrs == NULL ) {
435                                 printf( "ALL" );
436                         } else {
437                                 for ( i = 0; attrs[ i ] != NULL; ++i ) {
438                                         printf( "%s ", attrs[ i ] );
439                                 }
440                         }
441                         printf( "\n#\n\n" );
442                 }
443         }
444
445         if ( infile == NULL ) {
446                 rc = dosearch( ld, base, scope, attrs, attrsonly, NULL, filtpattern );
447
448         } else {
449                 rc = 0;
450                 first = 1;
451                 while ( rc == 0 && fgets( line, sizeof( line ), fp ) != NULL ) {
452                         line[ strlen( line ) - 1 ] = '\0';
453                         if ( !first ) {
454                                 putchar( '\n' );
455                         } else {
456                                 first = 0;
457                         }
458                         rc = dosearch( ld, base, scope, attrs, attrsonly,
459                                 filtpattern, line );
460                 }
461                 if ( fp != stdin ) {
462                         fclose( fp );
463                 }
464         }
465
466         ldap_unbind( ld );
467         return( rc );
468 }
469
470
471 static int dosearch(
472         LDAP    *ld,
473         char    *base,
474         int             scope,
475         char    **attrs,
476         int             attrsonly,
477         char    *filtpatt,
478         char    *value)
479 {
480         char            filter[ BUFSIZ ];
481         int                     rc, first, matches;
482         LDAPMessage             *res, *e;
483
484         if( filtpatt != NULL ) {
485                 sprintf( filter, filtpatt, value );
486
487                 if ( verbose ) {
488                         fprintf( stderr, "filter is: (%s)\n", filter );
489                 }
490
491                 if( ldif == 1 ) {
492                         printf( "#\n# filter: %s\n#\n", filter );
493                 }
494
495         } else {
496                 sprintf( filter, "%s", value );
497         }
498
499         if ( not ) {
500                 return( LDAP_SUCCESS );
501         }
502
503         if ( ldap_search( ld, base, scope, filter, attrs, attrsonly ) == -1 ) {
504                 int ld_errno;
505                 ldap_perror( ld, "ldap_search" );
506
507                 ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
508                 return( ld_errno );
509         }
510
511         matches = 0;
512         first = 1;
513         res = NULL;
514         while ( (rc = ldap_result( ld, LDAP_RES_ANY, sortattr ? 1 : 0, NULL, &res ))
515                 == LDAP_RES_SEARCH_ENTRY ) {
516         matches++;
517         e = ldap_first_entry( ld, res );
518         if ( !first ) {
519                 putchar( '\n' );
520         } else {
521                 first = 0;
522         }
523         print_entry( ld, e, attrsonly );
524         ldap_msgfree( res );
525         res = NULL;
526         }
527         if ( rc == -1 ) {
528         ldap_perror( ld, "ldap_result" );
529         return( rc );
530         }
531         if (( rc = ldap_result2error( ld, res, 0 )) != LDAP_SUCCESS ) {
532                 ldap_perror( ld, "ldap_search" );
533         }
534         if ( sortattr != NULL ) {
535                 (void) ldap_sort_entries( ld, &res,
536                         ( *sortattr == '\0' ) ? NULL : sortattr, strcasecmp );
537                 matches = 0;
538                 first = 1;
539                 for ( e = ldap_first_entry( ld, res ); e != NULL;
540                         e = ldap_next_entry( ld, e ) ) {
541                 matches++;
542                 if ( !first ) {
543                         putchar( '\n' );
544                 } else {
545                         first = 0;
546                 }
547                 print_entry( ld, e, attrsonly );
548                 }
549         }
550
551         if ( verbose ) {
552                 printf( "%d matches\n", matches );
553         }
554
555         ldap_msgfree( res );
556         return( rc );
557 }
558
559
560 void print_entry(
561         LDAP    *ld,
562         LDAPMessage     *entry,
563         int             attrsonly)
564 {
565         char            *a, *dn, *ufn;
566         char    tmpfname[ 256 ];
567         char    url[ 256 ];
568         int                     i;
569         BerElement              *ber = NULL;
570         struct berval   **bvals;
571         FILE            *tmpfp;
572
573         dn = ldap_get_dn( ld, entry );
574         ufn = NULL;
575
576         if ( ldif == 1 ) {
577                 ufn = ldap_dn2ufn( dn );
578                 write_ldif( LDIF_PUT_COMMENT, NULL, ufn, strlen( ufn ));
579         }
580         if ( ldif ) {
581                 write_ldif( LDIF_PUT_VALUE, "dn", dn, strlen( dn ));
582         } else {
583                 printf( "%s\n", dn );
584         }
585
586         if ( includeufn ) {
587                 if( ufn == NULL ) {
588                         ufn = ldap_dn2ufn( dn );
589                 }
590                 if ( ldif ) {
591                         write_ldif( LDIF_PUT_VALUE, "ufn", ufn, strlen( ufn ));
592                 } else {
593                         printf( "%s\n", ufn );
594                 }
595         }
596
597         if( ufn != NULL ) ldap_memfree( ufn );
598         ldap_memfree( dn );
599
600         for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL;
601                 a = ldap_next_attribute( ld, entry, ber ) )
602         {
603                 if ( skipsortattr && strcasecmp( a, sortattr ) == 0 ) {
604                         continue;
605                 }
606
607                 if ( attrsonly ) {
608                         if ( ldif ) {
609                                 write_ldif( LDIF_PUT_NOVALUE, a, NULL, 0 );
610                         } else {
611                                 printf( "%s\n", a );
612                         }
613
614                 } else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) {
615                         for ( i = 0; bvals[i] != NULL; i++ ) {
616                                 if ( vals2tmp > 1 || ( vals2tmp
617                                         && ldif_is_not_printable( bvals[i]->bv_val, bvals[i]->bv_len ) ))
618                                 {
619                                         /* write value to file */
620                                         sprintf( tmpfname, "%s" LDAP_DIRSEP "ldapsearch-%s-XXXXXX",
621                                                 tmpdir, a );
622                                         tmpfp = NULL;
623
624                                         if ( mktemp( tmpfname ) == NULL ) {
625                                                 perror( tmpfname );
626                                                 continue;
627                                         }
628
629                                         if (( tmpfp = fopen( tmpfname, "w")) == NULL ) {
630                                                 perror( tmpfname );
631                                                 continue;
632                                         }
633
634                                         if ( fwrite( bvals[ i ]->bv_val,
635                                                 bvals[ i ]->bv_len, 1, tmpfp ) == 0 )
636                                         {
637                                                 perror( tmpfname );
638                                                 fclose( tmpfp );
639                                                 continue;
640                                         }
641
642                                         fclose( tmpfp );
643
644                                         sprintf( url, "%s%s", urlpre,
645                                                 &tmpfname[strlen(tmpdir) + sizeof(LDAP_DIRSEP) - 1] );
646
647                                         if ( ldif ) {
648                                                 write_ldif( LDIF_PUT_URL, a, url, strlen( url ));
649                                         } else {
650                                                 printf( "%s%s%s\n", a, sep, url );
651                                         }
652
653
654                                 } else {
655                                         if ( ldif ) {
656                                                 write_ldif( LDIF_PUT_VALUE, a,
657                                                         bvals[ i ]->bv_val, bvals[ i ]->bv_len );
658
659                                         } else {
660                                                 int notprint = !binary && !vals2tmp
661                                                         && ldif_is_not_printable( bvals[i]->bv_val,
662                                                                 bvals[i]->bv_len ); 
663                                                 printf( "%s%s", a, sep );
664                                                 puts( notprint ? "NOT PRINTABLE" : bvals[ i ]->bv_val );
665                                                 puts( "\n" );
666                                         }
667                                 }
668                         }
669                         ber_bvecfree( bvals );
670                 }
671         }
672
673         if( ber != NULL ) {
674                 ber_free( ber, 0 );
675         }
676 }
677
678
679 int
680 write_ldif( int type, char *name, char *value, ber_len_t vallen )
681 {
682         char    *ldif;
683
684         if (( ldif = ldif_put( type, name, value, vallen )) == NULL ) {
685                 return( -1 );
686         }
687
688         fputs( ldif, stdout );
689         ber_memfree( ldif );
690
691         return( 0 );
692 }