10 #include <ac/unistd.h>
14 #ifdef HAVE_SYS_FILE_H
26 /* including the "internal" defs is legit and nec. since this test routine has
27 * a-priori knowledge of libldap internal workings.
28 * hodges@stanford.edu 5-Feb-96
32 static void handle_result LDAP_P(( LDAP *ld, LDAPMessage *lm ));
33 static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm, char *s ));
34 static void print_search_entry LDAP_P(( LDAP *ld, LDAPMessage *res ));
35 static void free_list LDAP_P(( char **list ));
37 #define NOCACHEERRMSG "don't compile with -DLDAP_NOCACHE if you desire local caching"
43 getline( char *line, int len, FILE *fp, char *prompt )
47 if ( fgets( line, len, fp ) == NULL )
50 line[ strlen( line ) - 1 ] = '\0';
57 get_list( char *prompt )
66 getline( buf, sizeof(buf), stdin, prompt );
71 if ( result == (char **) 0 )
72 result = (char **) malloc( sizeof(char *) );
74 result = (char **) realloc( result,
75 sizeof(char *) * (num + 1) );
77 result[num++] = (char *) strdup( buf );
79 if ( result == (char **) 0 )
81 result = (char **) realloc( result, sizeof(char *) * (num + 1) );
89 free_list( char **list )
94 for ( i = 0; list[ i ] != NULL; ++i ) {
103 file_read( char *path, struct berval *bv )
109 if (( fp = fopen( path, "r" )) == NULL ) {
114 if ( fseek( fp, 0L, SEEK_END ) != 0 ) {
120 bv->bv_len = ftell( fp );
122 if (( bv->bv_val = (char *)malloc( bv->bv_len )) == NULL ) {
128 if ( fseek( fp, 0L, SEEK_SET ) != 0 ) {
134 rlen = fread( bv->bv_val, 1, bv->bv_len, fp );
138 if ( (unsigned long) rlen != bv->bv_len ) {
144 return( bv->bv_len );
149 get_modlist( char *prompt1, char *prompt2, char *prompt3 )
151 static char buf[256];
155 struct berval **bvals;
161 getline( buf, sizeof(buf), stdin, prompt1 );
162 tmp.mod_op = atoi( buf );
164 if ( tmp.mod_op == -1 || buf[0] == '\0' )
168 getline( buf, sizeof(buf), stdin, prompt2 );
169 if ( buf[0] == '\0' )
171 tmp.mod_type = strdup( buf );
173 tmp.mod_values = get_list( prompt3 );
175 if ( tmp.mod_values != NULL ) {
178 for ( i = 0; tmp.mod_values[i] != NULL; ++i )
180 bvals = (struct berval **)calloc( i + 1,
181 sizeof( struct berval *));
182 for ( i = 0; tmp.mod_values[i] != NULL; ++i ) {
183 bvals[i] = (struct berval *)malloc(
184 sizeof( struct berval ));
185 if ( strncmp( tmp.mod_values[i], "{FILE}",
187 if ( file_read( tmp.mod_values[i] + 6,
192 bvals[i]->bv_val = tmp.mod_values[i];
194 strlen( tmp.mod_values[i] );
197 tmp.mod_bvalues = bvals;
198 tmp.mod_op |= LDAP_MOD_BVALUES;
201 if ( result == NULL )
202 result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
204 result = (LDAPMod **) realloc( result,
205 sizeof(LDAPMod *) * (num + 1) );
207 result[num] = (LDAPMod *) malloc( sizeof(LDAPMod) );
208 *(result[num]) = tmp; /* struct copy */
211 if ( result == NULL )
213 result = (LDAPMod **) realloc( result, sizeof(LDAPMod *) * (num + 1) );
220 #ifdef LDAP_REFERRALS
222 bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
225 static char dn[256], passwd[256];
229 getline( dn, sizeof(dn), stdin,
230 "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
231 if (( *authmethodp = atoi( dn )) == 3 ) {
232 *authmethodp = LDAP_AUTH_KRBV4;
234 *authmethodp |= 0x80;
236 #else /* HAVE_KERBEROS */
237 *authmethodp = LDAP_AUTH_SIMPLE;
238 #endif /* HAVE_KERBEROS */
240 getline( dn, sizeof(dn), stdin, "re-bind dn? " );
241 strcat( dn, dnsuffix );
244 if ( *authmethodp == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) {
245 getline( passwd, sizeof(passwd), stdin,
246 "re-bind password? " );
253 return( LDAP_SUCCESS );
255 #endif /* LDAP_REFERRALS */
259 main( int argc, char **argv )
262 int i, c, port, cldapflg, errflg, method, id, msgtype;
263 char line[256], command1, command2, command3;
264 char passwd[64], dn[256], rdn[64], attr[64], value[256];
265 char filter[256], *host, **types;
267 char *usage = "usage: %s [-u] [-h host] [-d level] [-s dnsuffix] [-p port] [-t file] [-T file]\n";
268 int bound, all, scope, attrsonly;
270 LDAPMod **mods, **attrs;
271 struct timeval timeout;
272 char *copyfname = NULL;
282 cldapflg = errflg = 0;
284 while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
287 #ifdef LDAP_CONNECTIONLESS
289 #else /* LDAP_CONNECTIONLESS */
290 printf( "Compile with -DLDAP_CONNECTIONLESS for UDP support\n" );
291 #endif /* LDAP_CONNECTIONLESS */
296 ldap_debug = atoi( optarg );
297 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
298 lber_debug = ldap_debug;
301 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
314 port = atoi( optarg );
317 case 't': /* copy ber's to given file */
318 copyfname = strdup( optarg );
319 copyoptions = LBER_TO_FILE;
322 case 'T': /* only output ber's to given file */
323 copyfname = strdup( optarg );
324 copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
332 if ( host == NULL && optind == argc - 1 ) {
333 host = argv[ optind ];
337 if ( errflg || optind < argc - 1 ) {
338 fprintf( stderr, usage, argv[ 0 ] );
342 printf( "%sldap_open( %s, %d )\n", cldapflg ? "c" : "",
343 host == NULL ? "(null)" : host, port );
346 #ifdef LDAP_CONNECTIONLESS
347 ld = cldap_open( host, port );
348 #endif /* LDAP_CONNECTIONLESS */
350 ld = ldap_open( host, port );
354 perror( "ldap_open" );
358 if ( copyfname != NULL ) {
359 if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
364 ld->ld_sb.sb_options = copyoptions;
371 (void) memset( line, '\0', sizeof(line) );
372 while ( getline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) {
377 switch ( command1 ) {
378 case 'a': /* add or abandon */
379 switch ( command2 ) {
381 getline( dn, sizeof(dn), stdin, "dn? " );
382 strcat( dn, dnsuffix );
383 if ( (attrs = get_modlist( NULL, "attr? ",
384 "value? " )) == NULL )
386 if ( (id = ldap_add( ld, dn, attrs )) == -1 )
387 ldap_perror( ld, "ldap_add" );
389 printf( "Add initiated with id %d\n",
393 case 'b': /* abandon */
394 getline( line, sizeof(line), stdin, "msgid? " );
396 if ( ldap_abandon( ld, id ) != 0 )
397 ldap_perror( ld, "ldap_abandon" );
399 printf( "Abandon successful\n" );
402 printf( "Possibilities: [ad]d, [ab]ort\n" );
406 case 'b': /* asynch bind */
408 getline( line, sizeof(line), stdin,
409 "method (0->simple, 1->krbv41, 2->krbv42)? " );
410 method = atoi( line ) | 0x80;
411 #else /* HAVE_KERBEROS */
412 method = LDAP_AUTH_SIMPLE;
413 #endif /* HAVE_KERBEROS */
414 getline( dn, sizeof(dn), stdin, "dn? " );
415 strcat( dn, dnsuffix );
417 if ( method == LDAP_AUTH_SIMPLE && dn[0] != '\0' )
418 getline( passwd, sizeof(passwd), stdin,
423 if ( ldap_bind( ld, dn, passwd, method ) == -1 ) {
424 fprintf( stderr, "ldap_bind failed\n" );
425 ldap_perror( ld, "ldap_bind" );
427 printf( "Bind initiated\n" );
432 case 'B': /* synch bind */
434 getline( line, sizeof(line), stdin,
435 "method 0->simple 1->krbv41 2->krbv42 3->krb? " );
436 method = atoi( line );
438 method = LDAP_AUTH_KRBV4;
440 method = method | 0x80;
441 #else /* HAVE_KERBEROS */
442 method = LDAP_AUTH_SIMPLE;
443 #endif /* HAVE_KERBEROS */
444 getline( dn, sizeof(dn), stdin, "dn? " );
445 strcat( dn, dnsuffix );
448 getline( passwd, sizeof(passwd), stdin,
453 if ( ldap_bind_s( ld, dn, passwd, method ) !=
455 fprintf( stderr, "ldap_bind_s failed\n" );
456 ldap_perror( ld, "ldap_bind_s" );
458 printf( "Bind successful\n" );
463 case 'c': /* compare */
464 getline( dn, sizeof(dn), stdin, "dn? " );
465 strcat( dn, dnsuffix );
466 getline( attr, sizeof(attr), stdin, "attr? " );
467 getline( value, sizeof(value), stdin, "value? " );
469 if ( (id = ldap_compare( ld, dn, attr, value )) == -1 )
470 ldap_perror( ld, "ldap_compare" );
472 printf( "Compare initiated with id %d\n", id );
475 case 'd': /* turn on debugging */
477 getline( line, sizeof(line), stdin, "debug level? " );
478 ldap_debug = atoi( line );
479 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
480 lber_debug = ldap_debug;
483 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
487 case 'E': /* explode a dn */
488 getline( line, sizeof(line), stdin, "dn? " );
489 exdn = ldap_explode_dn( line, 0 );
490 for ( i = 0; exdn != NULL && exdn[i] != NULL; i++ ) {
491 printf( "\t%s\n", exdn[i] );
495 case 'g': /* set next msgid */
496 getline( line, sizeof(line), stdin, "msgid? " );
497 ld->ld_msgid = atoi( line );
500 case 'v': /* set version number */
501 getline( line, sizeof(line), stdin, "version? " );
502 ld->ld_version = atoi( line );
505 case 'm': /* modify or modifyrdn */
506 if ( strncmp( line, "modify", 4 ) == 0 ) {
507 getline( dn, sizeof(dn), stdin, "dn? " );
508 strcat( dn, dnsuffix );
509 if ( (mods = get_modlist(
510 "mod (0=>add, 1=>delete, 2=>replace -1=>done)? ",
511 "attribute type? ", "attribute value? " ))
514 if ( (id = ldap_modify( ld, dn, mods )) == -1 )
515 ldap_perror( ld, "ldap_modify" );
517 printf( "Modify initiated with id %d\n",
519 } else if ( strncmp( line, "modrdn", 4 ) == 0 ) {
520 getline( dn, sizeof(dn), stdin, "dn? " );
521 strcat( dn, dnsuffix );
522 getline( rdn, sizeof(rdn), stdin, "newrdn? " );
523 if ( (id = ldap_modrdn( ld, dn, rdn )) == -1 )
524 ldap_perror( ld, "ldap_modrdn" );
526 printf( "Modrdn initiated with id %d\n",
529 printf( "Possibilities: [modi]fy, [modr]dn\n" );
534 #ifdef LDAP_CONNECTIONLESS
537 #endif /* LDAP_CONNECTIONLESS */
538 #ifdef LDAP_REFERRALS
540 #else /* LDAP_REFERRALS */
541 if ( !cldapflg && bound )
542 #endif /* LDAP_REFERRALS */
547 case 'r': /* result or remove */
548 switch ( command3 ) {
549 case 's': /* result */
550 getline( line, sizeof(line), stdin,
551 "msgid (-1=>any)? " );
552 if ( line[0] == '\0' )
556 getline( line, sizeof(line), stdin,
557 "all (0=>any, 1=>all)? " );
558 if ( line[0] == '\0' )
562 if (( msgtype = ldap_result( ld, id, all,
563 &timeout, &res )) < 1 ) {
564 ldap_perror( ld, "ldap_result" );
567 printf( "\nresult: msgtype %d msgid %d\n",
568 msgtype, res->lm_msgid );
569 handle_result( ld, res );
573 case 'm': /* remove */
574 getline( dn, sizeof(dn), stdin, "dn? " );
575 strcat( dn, dnsuffix );
576 if ( (id = ldap_delete( ld, dn )) == -1 )
577 ldap_perror( ld, "ldap_delete" );
579 printf( "Remove initiated with id %d\n",
584 printf( "Possibilities: [rem]ove, [res]ult\n" );
589 case 's': /* search */
590 getline( dn, sizeof(dn), stdin, "searchbase? " );
591 strcat( dn, dnsuffix );
592 getline( line, sizeof(line), stdin,
593 "scope (0=Base, 1=One Level, 2=Subtree)? " );
594 scope = atoi( line );
595 getline( filter, sizeof(filter), stdin,
596 "search filter (e.g. sn=jones)? " );
597 types = get_list( "attrs to return? " );
598 getline( line, sizeof(line), stdin,
599 "attrsonly (0=attrs&values, 1=attrs only)? " );
600 attrsonly = atoi( line );
603 #ifdef LDAP_CONNECTIONLESS
604 getline( line, sizeof(line), stdin,
605 "Requestor DN (for logging)? " );
606 if ( cldap_search_s( ld, dn, scope, filter, types,
607 attrsonly, &res, line ) != 0 ) {
608 ldap_perror( ld, "cldap_search_s" );
610 printf( "\nresult: msgid %d\n",
612 handle_result( ld, res );
615 #endif /* LDAP_CONNECTIONLESS */
617 if (( id = ldap_search( ld, dn, scope, filter,
618 types, attrsonly )) == -1 ) {
619 ldap_perror( ld, "ldap_search" );
621 printf( "Search initiated with id %d\n", id );
627 case 't': /* set timeout value */
628 getline( line, sizeof(line), stdin, "timeout? " );
629 timeout.tv_sec = atoi( line );
632 case 'U': /* set ufn search prefix */
633 getline( line, sizeof(line), stdin, "ufn prefix? " );
634 ldap_ufn_setprefix( ld, line );
637 case 'u': /* user friendly search w/optional timeout */
638 getline( dn, sizeof(dn), stdin, "ufn? " );
639 strcat( dn, dnsuffix );
640 types = get_list( "attrs to return? " );
641 getline( line, sizeof(line), stdin,
642 "attrsonly (0=attrs&values, 1=attrs only)? " );
643 attrsonly = atoi( line );
645 if ( command2 == 't' ) {
646 id = ldap_ufn_search_c( ld, dn, types,
647 attrsonly, &res, ldap_ufn_timeout,
650 id = ldap_ufn_search_s( ld, dn, types,
654 ldap_perror( ld, "ldap_ufn_search" );
656 printf( "\nresult: err %d\n", id );
657 handle_result( ld, res );
663 case 'l': /* URL search */
664 getline( line, sizeof(line), stdin,
665 "attrsonly (0=attrs&values, 1=attrs only)? " );
666 attrsonly = atoi( line );
667 getline( line, sizeof(line), stdin, "LDAP URL? " );
668 if (( id = ldap_url_search( ld, line, attrsonly ))
670 ldap_perror( ld, "ldap_url_search" );
672 printf( "URL search initiated with id %d\n", id );
676 case 'p': /* parse LDAP URL */
677 getline( line, sizeof(line), stdin, "LDAP URL? " );
678 if (( i = ldap_url_parse( line, &ludp )) != 0 ) {
679 fprintf( stderr, "ldap_url_parse: error %d\n", i );
681 printf( "\t host: " );
682 if ( ludp->lud_host == NULL ) {
683 printf( "DEFAULT\n" );
685 printf( "<%s>\n", ludp->lud_host );
687 printf( "\t port: " );
688 if ( ludp->lud_port == 0 ) {
689 printf( "DEFAULT\n" );
691 printf( "%d\n", ludp->lud_port );
693 printf( "\t dn: <%s>\n", ludp->lud_dn );
694 printf( "\t attrs:" );
695 if ( ludp->lud_attrs == NULL ) {
698 for ( i = 0; ludp->lud_attrs[ i ] != NULL; ++i ) {
699 printf( " <%s>", ludp->lud_attrs[ i ] );
702 printf( "\n\t scope: %s\n", ludp->lud_scope == LDAP_SCOPE_ONELEVEL ?
703 "ONE" : ludp->lud_scope == LDAP_SCOPE_BASE ? "BASE" :
704 ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
705 printf( "\tfilter: <%s>\n", ludp->lud_filter );
706 ldap_free_urldesc( ludp );
710 case 'n': /* set dn suffix, for convenience */
711 getline( line, sizeof(line), stdin, "DN suffix? " );
712 strcpy( dnsuffix, line );
715 case 'e': /* enable cache */
717 printf( NOCACHEERRMSG );
718 #else /* LDAP_NOCACHE */
719 getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
721 getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
722 if ( ldap_enable_cache( ld, i, atoi( line )) == 0 ) {
723 printf( "local cache is on\n" );
725 printf( "ldap_enable_cache failed\n" );
727 #endif /* LDAP_NOCACHE */
730 case 'x': /* uncache entry */
732 printf( NOCACHEERRMSG );
733 #else /* LDAP_NOCACHE */
734 getline( line, sizeof(line), stdin, "DN? " );
735 ldap_uncache_entry( ld, line );
736 #endif /* LDAP_NOCACHE */
739 case 'X': /* uncache request */
741 printf( NOCACHEERRMSG );
742 #else /* LDAP_NOCACHE */
743 getline( line, sizeof(line), stdin, "request msgid? " );
744 ldap_uncache_request( ld, atoi( line ));
745 #endif /* LDAP_NOCACHE */
748 case 'o': /* set ldap options */
749 getline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" );
750 ld->ld_deref = atoi( line );
751 getline( line, sizeof(line), stdin, "timelimit?" );
752 ld->ld_timelimit = atoi( line );
753 getline( line, sizeof(line), stdin, "sizelimit?" );
754 ld->ld_sizelimit = atoi( line );
758 #ifdef STR_TRANSLATION
759 getline( line, sizeof(line), stdin,
760 "Automatic translation of T.61 strings (0=no, 1=yes)?" );
761 if ( atoi( line ) == 0 ) {
762 ld->ld_lberoptions &= ~LBER_TRANSLATE_STRINGS;
764 ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS;
765 #ifdef LDAP_CHARSET_8859
766 getline( line, sizeof(line), stdin,
767 "Translate to/from ISO-8859 (0=no, 1=yes?" );
768 if ( atoi( line ) != 0 ) {
769 ldap_set_string_translators( ld,
773 #endif /* LDAP_CHARSET_8859 */
775 #endif /* STR_TRANSLATION */
778 getline( line, sizeof(line), stdin,
779 "Use DN & DNS to determine where to send requests (0=no, 1=yes)?" );
780 if ( atoi( line ) != 0 ) {
781 ld->ld_options |= LDAP_OPT_DNS;
783 #endif /* LDAP_DNS */
785 #ifdef LDAP_REFERRALS
786 getline( line, sizeof(line), stdin,
787 "Recognize and chase referrals (0=no, 1=yes)?" );
788 if ( atoi( line ) != 0 ) {
789 ld->ld_options |= LDAP_OPT_REFERRALS;
790 getline( line, sizeof(line), stdin,
791 "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" );
792 if ( atoi( line ) != 0 ) {
793 ldap_set_rebind_proc( ld, bind_prompt );
796 #endif /* LDAP_REFERRALS */
799 case 'O': /* set cache options */
801 printf( NOCACHEERRMSG );
802 #else /* LDAP_NOCACHE */
803 getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
804 switch( atoi( line )) {
806 ldap_set_cache_options( ld, 0 );
809 ldap_set_cache_options( ld,
810 LDAP_CACHE_OPT_CACHENOERRS );
813 ldap_set_cache_options( ld,
814 LDAP_CACHE_OPT_CACHEALLERRS );
817 printf( "not a valid cache option\n" );
819 #endif /* LDAP_NOCACHE */
823 printf( "Commands: [ad]d [ab]andon [b]ind\n" );
824 printf( " [B]ind async [c]ompare [l]URL search\n" );
825 printf( " [modi]fy [modr]dn [rem]ove\n" );
826 printf( " [res]ult [s]earch [q]uit/unbind\n\n" );
827 printf( " [u]fn search [ut]fn search with timeout\n" );
828 printf( " [d]ebug [e]nable cache set ms[g]id\n" );
829 printf( " d[n]suffix [t]imeout [v]ersion\n" );
830 printf( " [U]fn prefix [x]uncache entry [X]uncache request\n" );
831 printf( " [?]help [o]ptions [O]cache options\n" );
832 printf( " [E]xplode dn [p]arse LDAP URL\n" );
836 printf( "Invalid command. Type ? for help.\n" );
840 (void) memset( line, '\0', sizeof(line) );
847 handle_result( LDAP *ld, LDAPMessage *lm )
849 switch ( lm->lm_msgtype ) {
850 case LDAP_RES_COMPARE:
851 printf( "Compare result\n" );
852 print_ldap_result( ld, lm, "compare" );
855 case LDAP_RES_SEARCH_RESULT:
856 printf( "Search result\n" );
857 print_ldap_result( ld, lm, "search" );
860 case LDAP_RES_SEARCH_ENTRY:
861 printf( "Search entry\n" );
862 print_search_entry( ld, lm );
866 printf( "Add result\n" );
867 print_ldap_result( ld, lm, "add" );
870 case LDAP_RES_DELETE:
871 printf( "Delete result\n" );
872 print_ldap_result( ld, lm, "delete" );
875 case LDAP_RES_MODRDN:
876 printf( "ModRDN result\n" );
877 print_ldap_result( ld, lm, "modrdn" );
881 printf( "Bind result\n" );
882 print_ldap_result( ld, lm, "bind" );
886 printf( "Unknown result type 0x%x\n", lm->lm_msgtype );
887 print_ldap_result( ld, lm, "unknown" );
892 print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
894 ldap_result2error( ld, lm, 1 );
895 ldap_perror( ld, s );
897 if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
898 fprintf( stderr, "Additional info: %s\n", ld->ld_error );
899 if ( NAME_ERROR( ld->ld_errno ) && ld->ld_matched != NULL )
900 fprintf( stderr, "Matched DN: %s\n", ld->ld_matched );
905 print_search_entry( LDAP *ld, LDAPMessage *res )
909 struct berval **vals;
913 for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
914 e = ldap_next_entry( ld, e ) ) {
915 if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
918 dn = ldap_get_dn( ld, e );
919 printf( "\tDN: %s\n", dn );
921 ufn = ldap_dn2ufn( dn );
922 printf( "\tUFN: %s\n", ufn );
927 for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
928 a = ldap_next_attribute( ld, e, ber ) ) {
929 printf( "\t\tATTR: %s\n", a );
930 if ( (vals = ldap_get_values_len( ld, e, a ))
932 printf( "\t\t\t(no values)\n" );
934 for ( i = 0; vals[i] != NULL; i++ ) {
938 for ( j = 0; (unsigned long) j < vals[i]->bv_len; j++ )
939 if ( !isascii( vals[i]->bv_val[j] ) ) {
945 printf( "\t\t\tlength (%ld) (not ascii)\n", vals[i]->bv_len );
946 #ifdef BPRINT_NONASCII
947 lber_bprint( vals[i]->bv_val,
949 #endif /* BPRINT_NONASCII */
952 printf( "\t\t\tlength (%ld) %s\n",
953 vals[i]->bv_len, vals[i]->bv_val );
955 ber_bvecfree( vals );
960 if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT
961 || res->lm_chain != NULLMSG )
962 print_ldap_result( ld, res, "search" );