13 #if defined( DOS ) || defined( _WIN32 )
15 #if defined( WINSOCK ) || defined( _WIN32 )
19 #include <sys/types.h>
20 #include <sys/socket.h>
34 /* including the "internal" defs is legit and nec. since this test routine has
35 * a-priori knowledge of libldap internal workings.
36 * hodges@stanford.edu 5-Feb-96
40 #if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS )
42 #endif /* !PCNFS && !WINSOCK && !MACOS */
45 static void handle_result( LDAP *ld, LDAPMessage *lm );
46 static void print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s );
47 static void print_search_entry( LDAP *ld, LDAPMessage *res );
48 static void free_list( char **list );
50 static void handle_result();
51 static void print_ldap_result();
52 static void print_search_entry();
53 static void free_list();
54 #endif /* NEEDPROTOS */
56 #define NOCACHEERRMSG "don't compile with -DNO_CACHE if you desire local caching"
62 getline( char *line, int len, FILE *fp, char *prompt )
66 if ( fgets( line, len, fp ) == NULL )
69 line[ strlen( line ) - 1 ] = '\0';
76 get_list( char *prompt )
85 getline( buf, sizeof(buf), stdin, prompt );
90 if ( result == (char **) 0 )
91 result = (char **) malloc( sizeof(char *) );
93 result = (char **) realloc( result,
94 sizeof(char *) * (num + 1) );
96 result[num++] = (char *) strdup( buf );
98 if ( result == (char **) 0 )
100 result = (char **) realloc( result, sizeof(char *) * (num + 1) );
108 free_list( char **list )
112 if ( list != NULL ) {
113 for ( i = 0; list[ i ] != NULL; ++i ) {
116 free( (char *)list );
123 file_read( char *path, struct berval *bv )
129 if (( fp = fopen( path, "r" )) == NULL ) {
134 if ( fseek( fp, 0L, SEEK_END ) != 0 ) {
140 bv->bv_len = ftell( fp );
142 if (( bv->bv_val = (char *)malloc( bv->bv_len )) == NULL ) {
148 if ( fseek( fp, 0L, SEEK_SET ) != 0 ) {
154 rlen = fread( bv->bv_val, 1, bv->bv_len, fp );
158 if ( rlen != bv->bv_len ) {
164 return( bv->bv_len );
166 #endif /* MOD_USE_BVALS */
170 get_modlist( char *prompt1, char *prompt2, char *prompt3 )
172 static char buf[256];
177 struct berval **bvals;
178 #endif /* MOD_USE_BVALS */
184 getline( buf, sizeof(buf), stdin, prompt1 );
185 tmp.mod_op = atoi( buf );
187 if ( tmp.mod_op == -1 || buf[0] == '\0' )
191 getline( buf, sizeof(buf), stdin, prompt2 );
192 if ( buf[0] == '\0' )
194 tmp.mod_type = strdup( buf );
196 tmp.mod_values = get_list( prompt3 );
198 if ( tmp.mod_values != NULL ) {
201 for ( i = 0; tmp.mod_values[i] != NULL; ++i )
203 bvals = (struct berval **)calloc( i + 1,
204 sizeof( struct berval *));
205 for ( i = 0; tmp.mod_values[i] != NULL; ++i ) {
206 bvals[i] = (struct berval *)malloc(
207 sizeof( struct berval ));
208 if ( strncmp( tmp.mod_values[i], "{FILE}",
210 if ( file_read( tmp.mod_values[i] + 6,
215 bvals[i]->bv_val = tmp.mod_values[i];
217 strlen( tmp.mod_values[i] );
220 tmp.mod_bvalues = bvals;
221 tmp.mod_op |= LDAP_MOD_BVALUES;
223 #endif /* MOD_USE_BVALS */
225 if ( result == NULL )
226 result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
228 result = (LDAPMod **) realloc( result,
229 sizeof(LDAPMod *) * (num + 1) );
231 result[num] = (LDAPMod *) malloc( sizeof(LDAPMod) );
232 *(result[num]) = tmp; /* struct copy */
235 if ( result == NULL )
237 result = (LDAPMod **) realloc( result, sizeof(LDAPMod *) * (num + 1) );
244 #ifdef LDAP_REFERRALS
246 bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
249 static char dn[256], passwd[256];
253 getline( dn, sizeof(dn), stdin,
254 "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
255 if (( *authmethodp = atoi( dn )) == 3 ) {
256 *authmethodp = LDAP_AUTH_KRBV4;
258 *authmethodp |= 0x80;
261 *authmethodp = LDAP_AUTH_SIMPLE;
262 #endif /* KERBEROS */
264 getline( dn, sizeof(dn), stdin, "re-bind dn? " );
265 strcat( dn, dnsuffix );
268 if ( *authmethodp == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) {
269 getline( passwd, sizeof(passwd), stdin,
270 "re-bind password? " );
277 return( LDAP_SUCCESS );
279 #endif /* LDAP_REFERRALS */
288 int argc, char **argv )
291 int i, c, port, cldapflg, errflg, method, id, msgtype;
292 char line[256], command1, command2, command3;
293 char passwd[64], dn[256], rdn[64], attr[64], value[256];
294 char filter[256], *host, **types;
296 char *usage = "usage: %s [-u] [-h host] [-d level] [-s dnsuffix] [-p port] [-t file] [-T file]\n";
297 int bound, all, scope, attrsonly;
299 LDAPMod **mods, **attrs;
300 struct timeval timeout;
301 char *copyfname = NULL;
309 if (( argv = get_list( "cmd line arg?" )) == NULL ) {
312 for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
320 cldapflg = errflg = 0;
322 while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
328 printf( "Compile with -DCLDAP for UDP support\n" );
334 ldap_debug = atoi( optarg );
335 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
336 lber_debug = ldap_debug;
339 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
352 port = atoi( optarg );
355 #if !defined(MACOS) && !defined(DOS)
356 case 't': /* copy ber's to given file */
357 copyfname = strdup( optarg );
358 copyoptions = LBER_TO_FILE;
361 case 'T': /* only output ber's to given file */
362 copyfname = strdup( optarg );
363 copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
372 if ( host == NULL && optind == argc - 1 ) {
373 host = argv[ optind ];
377 if ( errflg || optind < argc - 1 ) {
378 fprintf( stderr, usage, argv[ 0 ] );
382 printf( "%sldap_open( %s, %d )\n", cldapflg ? "c" : "",
383 host == NULL ? "(null)" : host, port );
387 ld = cldap_open( host, port );
390 ld = ldap_open( host, port );
394 perror( "ldap_open" );
398 #if !defined(MACOS) && !defined(DOS)
399 if ( copyfname != NULL ) {
400 if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
405 ld->ld_sb.sb_options = copyoptions;
413 (void) memset( line, '\0', sizeof(line) );
414 while ( getline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) {
419 switch ( command1 ) {
420 case 'a': /* add or abandon */
421 switch ( command2 ) {
423 getline( dn, sizeof(dn), stdin, "dn? " );
424 strcat( dn, dnsuffix );
425 if ( (attrs = get_modlist( NULL, "attr? ",
426 "value? " )) == NULL )
428 if ( (id = ldap_add( ld, dn, attrs )) == -1 )
429 ldap_perror( ld, "ldap_add" );
431 printf( "Add initiated with id %d\n",
435 case 'b': /* abandon */
436 getline( line, sizeof(line), stdin, "msgid? " );
438 if ( ldap_abandon( ld, id ) != 0 )
439 ldap_perror( ld, "ldap_abandon" );
441 printf( "Abandon successful\n" );
444 printf( "Possibilities: [ad]d, [ab]ort\n" );
448 case 'b': /* asynch bind */
450 getline( line, sizeof(line), stdin,
451 "method (0->simple, 1->krbv41, 2->krbv42)? " );
452 method = atoi( line ) | 0x80;
454 method = LDAP_AUTH_SIMPLE;
455 #endif /* KERBEROS */
456 getline( dn, sizeof(dn), stdin, "dn? " );
457 strcat( dn, dnsuffix );
459 if ( method == LDAP_AUTH_SIMPLE && dn[0] != '\0' )
460 getline( passwd, sizeof(passwd), stdin,
465 if ( ldap_bind( ld, dn, passwd, method ) == -1 ) {
466 fprintf( stderr, "ldap_bind failed\n" );
467 ldap_perror( ld, "ldap_bind" );
469 printf( "Bind initiated\n" );
474 case 'B': /* synch bind */
476 getline( line, sizeof(line), stdin,
477 "method 0->simple 1->krbv41 2->krbv42 3->krb? " );
478 method = atoi( line );
480 method = LDAP_AUTH_KRBV4;
482 method = method | 0x80;
484 method = LDAP_AUTH_SIMPLE;
485 #endif /* KERBEROS */
486 getline( dn, sizeof(dn), stdin, "dn? " );
487 strcat( dn, dnsuffix );
490 getline( passwd, sizeof(passwd), stdin,
495 if ( ldap_bind_s( ld, dn, passwd, method ) !=
497 fprintf( stderr, "ldap_bind_s failed\n" );
498 ldap_perror( ld, "ldap_bind_s" );
500 printf( "Bind successful\n" );
505 case 'c': /* compare */
506 getline( dn, sizeof(dn), stdin, "dn? " );
507 strcat( dn, dnsuffix );
508 getline( attr, sizeof(attr), stdin, "attr? " );
509 getline( value, sizeof(value), stdin, "value? " );
511 if ( (id = ldap_compare( ld, dn, attr, value )) == -1 )
512 ldap_perror( ld, "ldap_compare" );
514 printf( "Compare initiated with id %d\n", id );
517 case 'd': /* turn on debugging */
519 getline( line, sizeof(line), stdin, "debug level? " );
520 ldap_debug = atoi( line );
521 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
522 lber_debug = ldap_debug;
525 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
529 case 'E': /* explode a dn */
530 getline( line, sizeof(line), stdin, "dn? " );
531 exdn = ldap_explode_dn( line, 0 );
532 for ( i = 0; exdn != NULL && exdn[i] != NULL; i++ ) {
533 printf( "\t%s\n", exdn[i] );
537 case 'g': /* set next msgid */
538 getline( line, sizeof(line), stdin, "msgid? " );
539 ld->ld_msgid = atoi( line );
542 case 'v': /* set version number */
543 getline( line, sizeof(line), stdin, "version? " );
544 ld->ld_version = atoi( line );
547 case 'm': /* modify or modifyrdn */
548 if ( strncmp( line, "modify", 4 ) == 0 ) {
549 getline( dn, sizeof(dn), stdin, "dn? " );
550 strcat( dn, dnsuffix );
551 if ( (mods = get_modlist(
552 "mod (0=>add, 1=>delete, 2=>replace -1=>done)? ",
553 "attribute type? ", "attribute value? " ))
556 if ( (id = ldap_modify( ld, dn, mods )) == -1 )
557 ldap_perror( ld, "ldap_modify" );
559 printf( "Modify initiated with id %d\n",
561 } else if ( strncmp( line, "modrdn", 4 ) == 0 ) {
562 getline( dn, sizeof(dn), stdin, "dn? " );
563 strcat( dn, dnsuffix );
564 getline( rdn, sizeof(rdn), stdin, "newrdn? " );
565 if ( (id = ldap_modrdn( ld, dn, rdn )) == -1 )
566 ldap_perror( ld, "ldap_modrdn" );
568 printf( "Modrdn initiated with id %d\n",
571 printf( "Possibilities: [modi]fy, [modr]dn\n" );
580 #ifdef LDAP_REFERRALS
582 #else /* LDAP_REFERRALS */
583 if ( !cldapflg && bound )
584 #endif /* LDAP_REFERRALS */
589 case 'r': /* result or remove */
590 switch ( command3 ) {
591 case 's': /* result */
592 getline( line, sizeof(line), stdin,
593 "msgid (-1=>any)? " );
594 if ( line[0] == '\0' )
598 getline( line, sizeof(line), stdin,
599 "all (0=>any, 1=>all)? " );
600 if ( line[0] == '\0' )
604 if (( msgtype = ldap_result( ld, id, all,
605 &timeout, &res )) < 1 ) {
606 ldap_perror( ld, "ldap_result" );
609 printf( "\nresult: msgtype %d msgid %d\n",
610 msgtype, res->lm_msgid );
611 handle_result( ld, res );
615 case 'm': /* remove */
616 getline( dn, sizeof(dn), stdin, "dn? " );
617 strcat( dn, dnsuffix );
618 if ( (id = ldap_delete( ld, dn )) == -1 )
619 ldap_perror( ld, "ldap_delete" );
621 printf( "Remove initiated with id %d\n",
626 printf( "Possibilities: [rem]ove, [res]ult\n" );
631 case 's': /* search */
632 getline( dn, sizeof(dn), stdin, "searchbase? " );
633 strcat( dn, dnsuffix );
634 getline( line, sizeof(line), stdin,
635 "scope (0=Base, 1=One Level, 2=Subtree)? " );
636 scope = atoi( line );
637 getline( filter, sizeof(filter), stdin,
638 "search filter (e.g. sn=jones)? " );
639 types = get_list( "attrs to return? " );
640 getline( line, sizeof(line), stdin,
641 "attrsonly (0=attrs&values, 1=attrs only)? " );
642 attrsonly = atoi( line );
646 getline( line, sizeof(line), stdin,
647 "Requestor DN (for logging)? " );
648 if ( cldap_search_s( ld, dn, scope, filter, types,
649 attrsonly, &res, line ) != 0 ) {
650 ldap_perror( ld, "cldap_search_s" );
652 printf( "\nresult: msgid %d\n",
654 handle_result( ld, res );
659 if (( id = ldap_search( ld, dn, scope, filter,
660 types, attrsonly )) == -1 ) {
661 ldap_perror( ld, "ldap_search" );
663 printf( "Search initiated with id %d\n", id );
669 case 't': /* set timeout value */
670 getline( line, sizeof(line), stdin, "timeout? " );
671 timeout.tv_sec = atoi( line );
674 case 'U': /* set ufn search prefix */
675 getline( line, sizeof(line), stdin, "ufn prefix? " );
676 ldap_ufn_setprefix( ld, line );
679 case 'u': /* user friendly search w/optional timeout */
680 getline( dn, sizeof(dn), stdin, "ufn? " );
681 strcat( dn, dnsuffix );
682 types = get_list( "attrs to return? " );
683 getline( line, sizeof(line), stdin,
684 "attrsonly (0=attrs&values, 1=attrs only)? " );
685 attrsonly = atoi( line );
687 if ( command2 == 't' ) {
688 id = ldap_ufn_search_c( ld, dn, types,
689 attrsonly, &res, ldap_ufn_timeout,
692 id = ldap_ufn_search_s( ld, dn, types,
696 ldap_perror( ld, "ldap_ufn_search" );
698 printf( "\nresult: err %d\n", id );
699 handle_result( ld, res );
705 case 'l': /* URL search */
706 getline( line, sizeof(line), stdin,
707 "attrsonly (0=attrs&values, 1=attrs only)? " );
708 attrsonly = atoi( line );
709 getline( line, sizeof(line), stdin, "LDAP URL? " );
710 if (( id = ldap_url_search( ld, line, attrsonly ))
712 ldap_perror( ld, "ldap_url_search" );
714 printf( "URL search initiated with id %d\n", id );
718 case 'p': /* parse LDAP URL */
719 getline( line, sizeof(line), stdin, "LDAP URL? " );
720 if (( i = ldap_url_parse( line, &ludp )) != 0 ) {
721 fprintf( stderr, "ldap_url_parse: error %d\n", i );
723 printf( "\t host: " );
724 if ( ludp->lud_host == NULL ) {
725 printf( "DEFAULT\n" );
727 printf( "<%s>\n", ludp->lud_host );
729 printf( "\t port: " );
730 if ( ludp->lud_port == 0 ) {
731 printf( "DEFAULT\n" );
733 printf( "%d\n", ludp->lud_port );
735 printf( "\t dn: <%s>\n", ludp->lud_dn );
736 printf( "\t attrs:" );
737 if ( ludp->lud_attrs == NULL ) {
740 for ( i = 0; ludp->lud_attrs[ i ] != NULL; ++i ) {
741 printf( " <%s>", ludp->lud_attrs[ i ] );
744 printf( "\n\t scope: %s\n", ludp->lud_scope == LDAP_SCOPE_ONELEVEL ?
745 "ONE" : ludp->lud_scope == LDAP_SCOPE_BASE ? "BASE" :
746 ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
747 printf( "\tfilter: <%s>\n", ludp->lud_filter );
748 ldap_free_urldesc( ludp );
752 case 'n': /* set dn suffix, for convenience */
753 getline( line, sizeof(line), stdin, "DN suffix? " );
754 strcpy( dnsuffix, line );
757 case 'e': /* enable cache */
759 printf( NOCACHEERRMSG );
761 getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
763 getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
764 if ( ldap_enable_cache( ld, i, atoi( line )) == 0 ) {
765 printf( "local cache is on\n" );
767 printf( "ldap_enable_cache failed\n" );
769 #endif /* NO_CACHE */
772 case 'x': /* uncache entry */
774 printf( NOCACHEERRMSG );
776 getline( line, sizeof(line), stdin, "DN? " );
777 ldap_uncache_entry( ld, line );
778 #endif /* NO_CACHE */
781 case 'X': /* uncache request */
783 printf( NOCACHEERRMSG );
785 getline( line, sizeof(line), stdin, "request msgid? " );
786 ldap_uncache_request( ld, atoi( line ));
787 #endif /* NO_CACHE */
790 case 'o': /* set ldap options */
791 getline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" );
792 ld->ld_deref = atoi( line );
793 getline( line, sizeof(line), stdin, "timelimit?" );
794 ld->ld_timelimit = atoi( line );
795 getline( line, sizeof(line), stdin, "sizelimit?" );
796 ld->ld_sizelimit = atoi( line );
800 #ifdef STR_TRANSLATION
801 getline( line, sizeof(line), stdin,
802 "Automatic translation of T.61 strings (0=no, 1=yes)?" );
803 if ( atoi( line ) == 0 ) {
804 ld->ld_lberoptions &= ~LBER_TRANSLATE_STRINGS;
806 ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS;
807 #ifdef LDAP_CHARSET_8859
808 getline( line, sizeof(line), stdin,
809 "Translate to/from ISO-8859 (0=no, 1=yes?" );
810 if ( atoi( line ) != 0 ) {
811 ldap_set_string_translators( ld,
815 #endif /* LDAP_CHARSET_8859 */
817 #endif /* STR_TRANSLATION */
820 getline( line, sizeof(line), stdin,
821 "Use DN & DNS to determine where to send requests (0=no, 1=yes)?" );
822 if ( atoi( line ) != 0 ) {
823 ld->ld_options |= LDAP_OPT_DNS;
825 #endif /* LDAP_DNS */
827 #ifdef LDAP_REFERRALS
828 getline( line, sizeof(line), stdin,
829 "Recognize and chase referrals (0=no, 1=yes)?" );
830 if ( atoi( line ) != 0 ) {
831 ld->ld_options |= LDAP_OPT_REFERRALS;
832 getline( line, sizeof(line), stdin,
833 "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" );
834 if ( atoi( line ) != 0 ) {
835 ldap_set_rebind_proc( ld, bind_prompt );
838 #endif /* LDAP_REFERRALS */
841 case 'O': /* set cache options */
843 printf( NOCACHEERRMSG );
845 getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
846 switch( atoi( line )) {
848 ldap_set_cache_options( ld, 0 );
851 ldap_set_cache_options( ld,
852 LDAP_CACHE_OPT_CACHENOERRS );
855 ldap_set_cache_options( ld,
856 LDAP_CACHE_OPT_CACHEALLERRS );
859 printf( "not a valid cache option\n" );
861 #endif /* NO_CACHE */
865 printf( "Commands: [ad]d [ab]andon [b]ind\n" );
866 printf( " [B]ind async [c]ompare [l]URL search\n" );
867 printf( " [modi]fy [modr]dn [rem]ove\n" );
868 printf( " [res]ult [s]earch [q]uit/unbind\n\n" );
869 printf( " [u]fn search [ut]fn search with timeout\n" );
870 printf( " [d]ebug [e]nable cache set ms[g]id\n" );
871 printf( " d[n]suffix [t]imeout [v]ersion\n" );
872 printf( " [U]fn prefix [x]uncache entry [X]uncache request\n" );
873 printf( " [?]help [o]ptions [O]cache options\n" );
874 printf( " [E]xplode dn [p]arse LDAP URL\n" );
878 printf( "Invalid command. Type ? for help.\n" );
882 (void) memset( line, '\0', sizeof(line) );
889 handle_result( LDAP *ld, LDAPMessage *lm )
891 switch ( lm->lm_msgtype ) {
892 case LDAP_RES_COMPARE:
893 printf( "Compare result\n" );
894 print_ldap_result( ld, lm, "compare" );
897 case LDAP_RES_SEARCH_RESULT:
898 printf( "Search result\n" );
899 print_ldap_result( ld, lm, "search" );
902 case LDAP_RES_SEARCH_ENTRY:
903 printf( "Search entry\n" );
904 print_search_entry( ld, lm );
908 printf( "Add result\n" );
909 print_ldap_result( ld, lm, "add" );
912 case LDAP_RES_DELETE:
913 printf( "Delete result\n" );
914 print_ldap_result( ld, lm, "delete" );
917 case LDAP_RES_MODRDN:
918 printf( "ModRDN result\n" );
919 print_ldap_result( ld, lm, "modrdn" );
923 printf( "Bind result\n" );
924 print_ldap_result( ld, lm, "bind" );
928 printf( "Unknown result type 0x%x\n", lm->lm_msgtype );
929 print_ldap_result( ld, lm, "unknown" );
934 print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
936 ldap_result2error( ld, lm, 1 );
937 ldap_perror( ld, s );
939 if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
940 fprintf( stderr, "Additional info: %s\n", ld->ld_error );
941 if ( NAME_ERROR( ld->ld_errno ) && ld->ld_matched != NULL )
942 fprintf( stderr, "Matched DN: %s\n", ld->ld_matched );
947 print_search_entry( LDAP *ld, LDAPMessage *res )
951 struct berval **vals;
955 for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
956 e = ldap_next_entry( ld, e ) ) {
957 if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
960 dn = ldap_get_dn( ld, e );
961 printf( "\tDN: %s\n", dn );
963 ufn = ldap_dn2ufn( dn );
964 printf( "\tUFN: %s\n", ufn );
973 for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
974 a = ldap_next_attribute( ld, e, ber ) ) {
975 printf( "\t\tATTR: %s\n", a );
976 if ( (vals = ldap_get_values_len( ld, e, a ))
978 printf( "\t\t\t(no values)\n" );
980 for ( i = 0; vals[i] != NULL; i++ ) {
984 for ( j = 0; j < vals[i]->bv_len; j++ )
985 if ( !isascii( vals[i]->bv_val[j] ) ) {
991 printf( "\t\t\tlength (%ld) (not ascii)\n", vals[i]->bv_len );
992 #ifdef BPRINT_NONASCII
993 lber_bprint( vals[i]->bv_val,
995 #endif /* BPRINT_NONASCII */
998 printf( "\t\t\tlength (%ld) %s\n",
999 vals[i]->bv_len, vals[i]->bv_val );
1001 ber_bvecfree( vals );
1006 if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT
1007 || res->lm_chain != NULLMSG )
1008 print_ldap_result( ld, res, "search" );
1014 ldap_perror( LDAP *ld, char *s )
1023 errs = ldap_err2string( ld->ld_errno );
1024 printf( "%s: %s\n", s, errs == NULL ? "unknown error" : errs );
1025 if ( ld->ld_error != NULL && *ld->ld_error != '\0' ) {
1026 printf( "%s: additional info: %s\n", s, ld->ld_error );
1029 #endif /* WINSOCK */