10 #include <ac/unistd.h>
14 #ifdef HAVE_SYS_FILE_H
23 /* including the "internal" defs is legit and nec. since this test routine has
24 * a-priori knowledge of libldap internal workings.
25 * hodges@stanford.edu 5-Feb-96
29 static void handle_result LDAP_P(( LDAP *ld, LDAPMessage *lm ));
30 static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm, char *s ));
31 static void print_search_entry LDAP_P(( LDAP *ld, LDAPMessage *res ));
32 static void free_list LDAP_P(( char **list ));
34 #define NOCACHEERRMSG "don't compile with -DLDAP_NOCACHE if you desire local caching"
40 getline( char *line, int len, FILE *fp, char *prompt )
44 if ( fgets( line, len, fp ) == NULL )
47 line[ strlen( line ) - 1 ] = '\0';
54 get_list( char *prompt )
63 getline( buf, sizeof(buf), stdin, prompt );
68 if ( result == (char **) 0 )
69 result = (char **) malloc( sizeof(char *) );
71 result = (char **) realloc( result,
72 sizeof(char *) * (num + 1) );
74 result[num++] = (char *) strdup( buf );
76 if ( result == (char **) 0 )
78 result = (char **) realloc( result, sizeof(char *) * (num + 1) );
86 free_list( char **list )
91 for ( i = 0; list[ i ] != NULL; ++i ) {
100 file_read( char *path, struct berval *bv )
106 if (( fp = fopen( path, "r" )) == NULL ) {
111 if ( fseek( fp, 0L, SEEK_END ) != 0 ) {
117 bv->bv_len = ftell( fp );
119 if (( bv->bv_val = (char *)malloc( bv->bv_len )) == NULL ) {
125 if ( fseek( fp, 0L, SEEK_SET ) != 0 ) {
131 rlen = fread( bv->bv_val, 1, bv->bv_len, fp );
135 if ( (unsigned long) rlen != bv->bv_len ) {
141 return( bv->bv_len );
146 get_modlist( char *prompt1, char *prompt2, char *prompt3 )
148 static char buf[256];
152 struct berval **bvals;
158 getline( buf, sizeof(buf), stdin, prompt1 );
159 tmp.mod_op = atoi( buf );
161 if ( tmp.mod_op == -1 || buf[0] == '\0' )
165 getline( buf, sizeof(buf), stdin, prompt2 );
166 if ( buf[0] == '\0' )
168 tmp.mod_type = strdup( buf );
170 tmp.mod_values = get_list( prompt3 );
172 if ( tmp.mod_values != NULL ) {
175 for ( i = 0; tmp.mod_values[i] != NULL; ++i )
177 bvals = (struct berval **)calloc( i + 1,
178 sizeof( struct berval *));
179 for ( i = 0; tmp.mod_values[i] != NULL; ++i ) {
180 bvals[i] = (struct berval *)malloc(
181 sizeof( struct berval ));
182 if ( strncmp( tmp.mod_values[i], "{FILE}",
184 if ( file_read( tmp.mod_values[i] + 6,
189 bvals[i]->bv_val = tmp.mod_values[i];
191 strlen( tmp.mod_values[i] );
194 tmp.mod_bvalues = bvals;
195 tmp.mod_op |= LDAP_MOD_BVALUES;
198 if ( result == NULL )
199 result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
201 result = (LDAPMod **) realloc( result,
202 sizeof(LDAPMod *) * (num + 1) );
204 result[num] = (LDAPMod *) malloc( sizeof(LDAPMod) );
205 *(result[num]) = tmp; /* struct copy */
208 if ( result == NULL )
210 result = (LDAPMod **) realloc( result, sizeof(LDAPMod *) * (num + 1) );
217 #ifdef LDAP_REFERRALS
219 bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
222 static char dn[256], passwd[256];
226 getline( dn, sizeof(dn), stdin,
227 "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
228 if (( *authmethodp = atoi( dn )) == 3 ) {
229 *authmethodp = LDAP_AUTH_KRBV4;
231 *authmethodp |= 0x80;
233 #else /* HAVE_KERBEROS */
234 *authmethodp = LDAP_AUTH_SIMPLE;
235 #endif /* HAVE_KERBEROS */
237 getline( dn, sizeof(dn), stdin, "re-bind dn? " );
238 strcat( dn, dnsuffix );
241 if ( *authmethodp == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) {
242 getline( passwd, sizeof(passwd), stdin,
243 "re-bind password? " );
250 return( LDAP_SUCCESS );
252 #endif /* LDAP_REFERRALS */
256 main( int argc, char **argv )
259 int i, c, port, cldapflg, errflg, method, id, msgtype;
260 char line[256], command1, command2, command3;
261 char passwd[64], dn[256], rdn[64], attr[64], value[256];
262 char filter[256], *host, **types;
264 char *usage = "usage: %s [-u] [-h host] [-d level] [-s dnsuffix] [-p port] [-t file] [-T file]\n";
265 int bound, all, scope, attrsonly;
267 LDAPMod **mods, **attrs;
268 struct timeval timeout;
269 char *copyfname = NULL;
279 cldapflg = errflg = 0;
281 while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
284 #ifdef LDAP_CONNECTIONLESS
286 #else /* LDAP_CONNECTIONLESS */
287 printf( "Compile with -DLDAP_CONNECTIONLESS for UDP support\n" );
288 #endif /* LDAP_CONNECTIONLESS */
293 ldap_debug = atoi( optarg );
294 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
295 lber_debug = ldap_debug;
298 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
311 port = atoi( optarg );
314 case 't': /* copy ber's to given file */
315 copyfname = strdup( optarg );
316 copyoptions = LBER_TO_FILE;
319 case 'T': /* only output ber's to given file */
320 copyfname = strdup( optarg );
321 copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
329 if ( host == NULL && optind == argc - 1 ) {
330 host = argv[ optind ];
334 if ( errflg || optind < argc - 1 ) {
335 fprintf( stderr, usage, argv[ 0 ] );
339 printf( "%sldap_open( %s, %d )\n", cldapflg ? "c" : "",
340 host == NULL ? "(null)" : host, port );
343 #ifdef LDAP_CONNECTIONLESS
344 ld = cldap_open( host, port );
345 #endif /* LDAP_CONNECTIONLESS */
347 ld = ldap_open( host, port );
351 perror( "ldap_open" );
355 if ( copyfname != NULL ) {
356 if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
361 ld->ld_sb.sb_options = copyoptions;
368 (void) memset( line, '\0', sizeof(line) );
369 while ( getline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) {
374 switch ( command1 ) {
375 case 'a': /* add or abandon */
376 switch ( command2 ) {
378 getline( dn, sizeof(dn), stdin, "dn? " );
379 strcat( dn, dnsuffix );
380 if ( (attrs = get_modlist( NULL, "attr? ",
381 "value? " )) == NULL )
383 if ( (id = ldap_add( ld, dn, attrs )) == -1 )
384 ldap_perror( ld, "ldap_add" );
386 printf( "Add initiated with id %d\n",
390 case 'b': /* abandon */
391 getline( line, sizeof(line), stdin, "msgid? " );
393 if ( ldap_abandon( ld, id ) != 0 )
394 ldap_perror( ld, "ldap_abandon" );
396 printf( "Abandon successful\n" );
399 printf( "Possibilities: [ad]d, [ab]ort\n" );
403 case 'b': /* asynch bind */
405 getline( line, sizeof(line), stdin,
406 "method (0->simple, 1->krbv41, 2->krbv42)? " );
407 method = atoi( line ) | 0x80;
408 #else /* HAVE_KERBEROS */
409 method = LDAP_AUTH_SIMPLE;
410 #endif /* HAVE_KERBEROS */
411 getline( dn, sizeof(dn), stdin, "dn? " );
412 strcat( dn, dnsuffix );
414 if ( method == LDAP_AUTH_SIMPLE && dn[0] != '\0' )
415 getline( passwd, sizeof(passwd), stdin,
420 if ( ldap_bind( ld, dn, passwd, method ) == -1 ) {
421 fprintf( stderr, "ldap_bind failed\n" );
422 ldap_perror( ld, "ldap_bind" );
424 printf( "Bind initiated\n" );
429 case 'B': /* synch bind */
431 getline( line, sizeof(line), stdin,
432 "method 0->simple 1->krbv41 2->krbv42 3->krb? " );
433 method = atoi( line );
435 method = LDAP_AUTH_KRBV4;
437 method = method | 0x80;
438 #else /* HAVE_KERBEROS */
439 method = LDAP_AUTH_SIMPLE;
440 #endif /* HAVE_KERBEROS */
441 getline( dn, sizeof(dn), stdin, "dn? " );
442 strcat( dn, dnsuffix );
445 getline( passwd, sizeof(passwd), stdin,
450 if ( ldap_bind_s( ld, dn, passwd, method ) !=
452 fprintf( stderr, "ldap_bind_s failed\n" );
453 ldap_perror( ld, "ldap_bind_s" );
455 printf( "Bind successful\n" );
460 case 'c': /* compare */
461 getline( dn, sizeof(dn), stdin, "dn? " );
462 strcat( dn, dnsuffix );
463 getline( attr, sizeof(attr), stdin, "attr? " );
464 getline( value, sizeof(value), stdin, "value? " );
466 if ( (id = ldap_compare( ld, dn, attr, value )) == -1 )
467 ldap_perror( ld, "ldap_compare" );
469 printf( "Compare initiated with id %d\n", id );
472 case 'd': /* turn on debugging */
474 getline( line, sizeof(line), stdin, "debug level? " );
475 ldap_debug = atoi( line );
476 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
477 lber_debug = ldap_debug;
480 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
484 case 'E': /* explode a dn */
485 getline( line, sizeof(line), stdin, "dn? " );
486 exdn = ldap_explode_dn( line, 0 );
487 for ( i = 0; exdn != NULL && exdn[i] != NULL; i++ ) {
488 printf( "\t%s\n", exdn[i] );
492 case 'g': /* set next msgid */
493 getline( line, sizeof(line), stdin, "msgid? " );
494 ld->ld_msgid = atoi( line );
497 case 'v': /* set version number */
498 getline( line, sizeof(line), stdin, "version? " );
499 ld->ld_version = atoi( line );
502 case 'm': /* modify or modifyrdn */
503 if ( strncmp( line, "modify", 4 ) == 0 ) {
504 getline( dn, sizeof(dn), stdin, "dn? " );
505 strcat( dn, dnsuffix );
506 if ( (mods = get_modlist(
507 "mod (0=>add, 1=>delete, 2=>replace -1=>done)? ",
508 "attribute type? ", "attribute value? " ))
511 if ( (id = ldap_modify( ld, dn, mods )) == -1 )
512 ldap_perror( ld, "ldap_modify" );
514 printf( "Modify initiated with id %d\n",
516 } else if ( strncmp( line, "modrdn", 4 ) == 0 ) {
517 getline( dn, sizeof(dn), stdin, "dn? " );
518 strcat( dn, dnsuffix );
519 getline( rdn, sizeof(rdn), stdin, "newrdn? " );
520 if ( (id = ldap_modrdn( ld, dn, rdn )) == -1 )
521 ldap_perror( ld, "ldap_modrdn" );
523 printf( "Modrdn initiated with id %d\n",
526 printf( "Possibilities: [modi]fy, [modr]dn\n" );
531 #ifdef LDAP_CONNECTIONLESS
534 #endif /* LDAP_CONNECTIONLESS */
535 #ifdef LDAP_REFERRALS
537 #else /* LDAP_REFERRALS */
538 if ( !cldapflg && bound )
539 #endif /* LDAP_REFERRALS */
544 case 'r': /* result or remove */
545 switch ( command3 ) {
546 case 's': /* result */
547 getline( line, sizeof(line), stdin,
548 "msgid (-1=>any)? " );
549 if ( line[0] == '\0' )
553 getline( line, sizeof(line), stdin,
554 "all (0=>any, 1=>all)? " );
555 if ( line[0] == '\0' )
559 if (( msgtype = ldap_result( ld, id, all,
560 &timeout, &res )) < 1 ) {
561 ldap_perror( ld, "ldap_result" );
564 printf( "\nresult: msgtype %d msgid %d\n",
565 msgtype, res->lm_msgid );
566 handle_result( ld, res );
570 case 'm': /* remove */
571 getline( dn, sizeof(dn), stdin, "dn? " );
572 strcat( dn, dnsuffix );
573 if ( (id = ldap_delete( ld, dn )) == -1 )
574 ldap_perror( ld, "ldap_delete" );
576 printf( "Remove initiated with id %d\n",
581 printf( "Possibilities: [rem]ove, [res]ult\n" );
586 case 's': /* search */
587 getline( dn, sizeof(dn), stdin, "searchbase? " );
588 strcat( dn, dnsuffix );
589 getline( line, sizeof(line), stdin,
590 "scope (0=Base, 1=One Level, 2=Subtree)? " );
591 scope = atoi( line );
592 getline( filter, sizeof(filter), stdin,
593 "search filter (e.g. sn=jones)? " );
594 types = get_list( "attrs to return? " );
595 getline( line, sizeof(line), stdin,
596 "attrsonly (0=attrs&values, 1=attrs only)? " );
597 attrsonly = atoi( line );
600 #ifdef LDAP_CONNECTIONLESS
601 getline( line, sizeof(line), stdin,
602 "Requestor DN (for logging)? " );
603 if ( cldap_search_s( ld, dn, scope, filter, types,
604 attrsonly, &res, line ) != 0 ) {
605 ldap_perror( ld, "cldap_search_s" );
607 printf( "\nresult: msgid %d\n",
609 handle_result( ld, res );
612 #endif /* LDAP_CONNECTIONLESS */
614 if (( id = ldap_search( ld, dn, scope, filter,
615 types, attrsonly )) == -1 ) {
616 ldap_perror( ld, "ldap_search" );
618 printf( "Search initiated with id %d\n", id );
624 case 't': /* set timeout value */
625 getline( line, sizeof(line), stdin, "timeout? " );
626 timeout.tv_sec = atoi( line );
629 case 'U': /* set ufn search prefix */
630 getline( line, sizeof(line), stdin, "ufn prefix? " );
631 ldap_ufn_setprefix( ld, line );
634 case 'u': /* user friendly search w/optional timeout */
635 getline( dn, sizeof(dn), stdin, "ufn? " );
636 strcat( dn, dnsuffix );
637 types = get_list( "attrs to return? " );
638 getline( line, sizeof(line), stdin,
639 "attrsonly (0=attrs&values, 1=attrs only)? " );
640 attrsonly = atoi( line );
642 if ( command2 == 't' ) {
643 id = ldap_ufn_search_c( ld, dn, types,
644 attrsonly, &res, ldap_ufn_timeout,
647 id = ldap_ufn_search_s( ld, dn, types,
651 ldap_perror( ld, "ldap_ufn_search" );
653 printf( "\nresult: err %d\n", id );
654 handle_result( ld, res );
660 case 'l': /* URL search */
661 getline( line, sizeof(line), stdin,
662 "attrsonly (0=attrs&values, 1=attrs only)? " );
663 attrsonly = atoi( line );
664 getline( line, sizeof(line), stdin, "LDAP URL? " );
665 if (( id = ldap_url_search( ld, line, attrsonly ))
667 ldap_perror( ld, "ldap_url_search" );
669 printf( "URL search initiated with id %d\n", id );
673 case 'p': /* parse LDAP URL */
674 getline( line, sizeof(line), stdin, "LDAP URL? " );
675 if (( i = ldap_url_parse( line, &ludp )) != 0 ) {
676 fprintf( stderr, "ldap_url_parse: error %d\n", i );
678 printf( "\t host: " );
679 if ( ludp->lud_host == NULL ) {
680 printf( "DEFAULT\n" );
682 printf( "<%s>\n", ludp->lud_host );
684 printf( "\t port: " );
685 if ( ludp->lud_port == 0 ) {
686 printf( "DEFAULT\n" );
688 printf( "%d\n", ludp->lud_port );
690 printf( "\t dn: <%s>\n", ludp->lud_dn );
691 printf( "\t attrs:" );
692 if ( ludp->lud_attrs == NULL ) {
695 for ( i = 0; ludp->lud_attrs[ i ] != NULL; ++i ) {
696 printf( " <%s>", ludp->lud_attrs[ i ] );
699 printf( "\n\t scope: %s\n", ludp->lud_scope == LDAP_SCOPE_ONELEVEL ?
700 "ONE" : ludp->lud_scope == LDAP_SCOPE_BASE ? "BASE" :
701 ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
702 printf( "\tfilter: <%s>\n", ludp->lud_filter );
703 ldap_free_urldesc( ludp );
707 case 'n': /* set dn suffix, for convenience */
708 getline( line, sizeof(line), stdin, "DN suffix? " );
709 strcpy( dnsuffix, line );
712 case 'e': /* enable cache */
714 printf( NOCACHEERRMSG );
715 #else /* LDAP_NOCACHE */
716 getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
718 getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
719 if ( ldap_enable_cache( ld, i, atoi( line )) == 0 ) {
720 printf( "local cache is on\n" );
722 printf( "ldap_enable_cache failed\n" );
724 #endif /* LDAP_NOCACHE */
727 case 'x': /* uncache entry */
729 printf( NOCACHEERRMSG );
730 #else /* LDAP_NOCACHE */
731 getline( line, sizeof(line), stdin, "DN? " );
732 ldap_uncache_entry( ld, line );
733 #endif /* LDAP_NOCACHE */
736 case 'X': /* uncache request */
738 printf( NOCACHEERRMSG );
739 #else /* LDAP_NOCACHE */
740 getline( line, sizeof(line), stdin, "request msgid? " );
741 ldap_uncache_request( ld, atoi( line ));
742 #endif /* LDAP_NOCACHE */
745 case 'o': /* set ldap options */
746 getline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" );
747 ld->ld_deref = atoi( line );
748 getline( line, sizeof(line), stdin, "timelimit?" );
749 ld->ld_timelimit = atoi( line );
750 getline( line, sizeof(line), stdin, "sizelimit?" );
751 ld->ld_sizelimit = atoi( line );
755 #ifdef STR_TRANSLATION
756 getline( line, sizeof(line), stdin,
757 "Automatic translation of T.61 strings (0=no, 1=yes)?" );
758 if ( atoi( line ) == 0 ) {
759 ld->ld_lberoptions &= ~LBER_TRANSLATE_STRINGS;
761 ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS;
762 #ifdef LDAP_CHARSET_8859
763 getline( line, sizeof(line), stdin,
764 "Translate to/from ISO-8859 (0=no, 1=yes?" );
765 if ( atoi( line ) != 0 ) {
766 ldap_set_string_translators( ld,
770 #endif /* LDAP_CHARSET_8859 */
772 #endif /* STR_TRANSLATION */
775 getline( line, sizeof(line), stdin,
776 "Use DN & DNS to determine where to send requests (0=no, 1=yes)?" );
777 if ( atoi( line ) != 0 ) {
778 LDAP_BOOL_SET(ld, LDAP_BOOL_DNS);
780 #endif /* LDAP_DNS */
782 #ifdef LDAP_REFERRALS
783 getline( line, sizeof(line), stdin,
784 "Recognize and chase referrals (0=no, 1=yes)?" );
785 if ( atoi( line ) != 0 ) {
786 LDAP_BOOL_SET(ld, LDAP_BOOL_REFERRALS);
787 getline( line, sizeof(line), stdin,
788 "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" );
789 if ( atoi( line ) != 0 ) {
790 ldap_set_rebind_proc( ld, bind_prompt );
793 #endif /* LDAP_REFERRALS */
796 case 'O': /* set cache options */
798 printf( NOCACHEERRMSG );
799 #else /* LDAP_NOCACHE */
800 getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
801 switch( atoi( line )) {
803 ldap_set_cache_options( ld, 0 );
806 ldap_set_cache_options( ld,
807 LDAP_CACHE_OPT_CACHENOERRS );
810 ldap_set_cache_options( ld,
811 LDAP_CACHE_OPT_CACHEALLERRS );
814 printf( "not a valid cache option\n" );
816 #endif /* LDAP_NOCACHE */
820 printf( "Commands: [ad]d [ab]andon [b]ind\n" );
821 printf( " [B]ind async [c]ompare [l]URL search\n" );
822 printf( " [modi]fy [modr]dn [rem]ove\n" );
823 printf( " [res]ult [s]earch [q]uit/unbind\n\n" );
824 printf( " [u]fn search [ut]fn search with timeout\n" );
825 printf( " [d]ebug [e]nable cache set ms[g]id\n" );
826 printf( " d[n]suffix [t]imeout [v]ersion\n" );
827 printf( " [U]fn prefix [x]uncache entry [X]uncache request\n" );
828 printf( " [?]help [o]ptions [O]cache options\n" );
829 printf( " [E]xplode dn [p]arse LDAP URL\n" );
833 printf( "Invalid command. Type ? for help.\n" );
837 (void) memset( line, '\0', sizeof(line) );
844 handle_result( LDAP *ld, LDAPMessage *lm )
846 switch ( lm->lm_msgtype ) {
847 case LDAP_RES_COMPARE:
848 printf( "Compare result\n" );
849 print_ldap_result( ld, lm, "compare" );
852 case LDAP_RES_SEARCH_RESULT:
853 printf( "Search result\n" );
854 print_ldap_result( ld, lm, "search" );
857 case LDAP_RES_SEARCH_ENTRY:
858 printf( "Search entry\n" );
859 print_search_entry( ld, lm );
863 printf( "Add result\n" );
864 print_ldap_result( ld, lm, "add" );
867 case LDAP_RES_DELETE:
868 printf( "Delete result\n" );
869 print_ldap_result( ld, lm, "delete" );
872 case LDAP_RES_MODRDN:
873 printf( "ModRDN result\n" );
874 print_ldap_result( ld, lm, "modrdn" );
878 printf( "Bind result\n" );
879 print_ldap_result( ld, lm, "bind" );
883 printf( "Unknown result type 0x%x\n", lm->lm_msgtype );
884 print_ldap_result( ld, lm, "unknown" );
889 print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
891 ldap_result2error( ld, lm, 1 );
892 ldap_perror( ld, s );
894 if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
895 fprintf( stderr, "Additional info: %s\n", ld->ld_error );
896 if ( NAME_ERROR( ld->ld_errno ) && ld->ld_matched != NULL )
897 fprintf( stderr, "Matched DN: %s\n", ld->ld_matched );
902 print_search_entry( LDAP *ld, LDAPMessage *res )
906 struct berval **vals;
910 for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
911 e = ldap_next_entry( ld, e ) ) {
912 if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
915 dn = ldap_get_dn( ld, e );
916 printf( "\tDN: %s\n", dn );
918 ufn = ldap_dn2ufn( dn );
919 printf( "\tUFN: %s\n", ufn );
924 for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
925 a = ldap_next_attribute( ld, e, ber ) ) {
926 printf( "\t\tATTR: %s\n", a );
927 if ( (vals = ldap_get_values_len( ld, e, a ))
929 printf( "\t\t\t(no values)\n" );
931 for ( i = 0; vals[i] != NULL; i++ ) {
935 for ( j = 0; (unsigned long) j < vals[i]->bv_len; j++ )
936 if ( !isascii( vals[i]->bv_val[j] ) ) {
942 printf( "\t\t\tlength (%ld) (not ascii)\n", vals[i]->bv_len );
943 #ifdef BPRINT_NONASCII
944 lber_bprint( vals[i]->bv_val,
946 #endif /* BPRINT_NONASCII */
949 printf( "\t\t\tlength (%ld) %s\n",
950 vals[i]->bv_len, vals[i]->bv_val );
952 ber_bvecfree( vals );
957 if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT
958 || res->lm_chain != NULLMSG )
959 print_ldap_result( ld, res, "search" );