14 #if defined( DOS ) || defined( _WIN32 )
16 #if defined( WINSOCK ) || defined( _WIN32 )
20 #include <sys/types.h>
21 #include <sys/socket.h>
35 /* including the "internal" defs is legit and nec. since this test routine has
36 * a-priori knowledge of libldap internal workings.
37 * hodges@stanford.edu 5-Feb-96
41 #if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS )
43 #endif /* !PCNFS && !WINSOCK && !MACOS */
46 static void handle_result( LDAP *ld, LDAPMessage *lm );
47 static void print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s );
48 static void print_search_entry( LDAP *ld, LDAPMessage *res );
49 static void free_list( char **list );
51 static void handle_result();
52 static void print_ldap_result();
53 static void print_search_entry();
54 static void free_list();
55 #endif /* NEEDPROTOS */
57 #define NOCACHEERRMSG "don't compile with -DNO_CACHE if you desire local caching"
63 getline( char *line, int len, FILE *fp, char *prompt )
67 if ( fgets( line, len, fp ) == NULL )
70 line[ strlen( line ) - 1 ] = '\0';
77 get_list( char *prompt )
86 getline( buf, sizeof(buf), stdin, prompt );
91 if ( result == (char **) 0 )
92 result = (char **) malloc( sizeof(char *) );
94 result = (char **) realloc( result,
95 sizeof(char *) * (num + 1) );
97 result[num++] = (char *) strdup( buf );
99 if ( result == (char **) 0 )
101 result = (char **) realloc( result, sizeof(char *) * (num + 1) );
109 free_list( char **list )
113 if ( list != NULL ) {
114 for ( i = 0; list[ i ] != NULL; ++i ) {
117 free( (char *)list );
124 file_read( char *path, struct berval *bv )
130 if (( fp = fopen( path, "r" )) == NULL ) {
135 if ( fseek( fp, 0L, SEEK_END ) != 0 ) {
141 bv->bv_len = ftell( fp );
143 if (( bv->bv_val = (char *)malloc( bv->bv_len )) == NULL ) {
149 if ( fseek( fp, 0L, SEEK_SET ) != 0 ) {
155 rlen = fread( bv->bv_val, 1, bv->bv_len, fp );
159 if ( rlen != bv->bv_len ) {
165 return( bv->bv_len );
167 #endif /* MOD_USE_BVALS */
171 get_modlist( char *prompt1, char *prompt2, char *prompt3 )
173 static char buf[256];
178 struct berval **bvals;
179 #endif /* MOD_USE_BVALS */
185 getline( buf, sizeof(buf), stdin, prompt1 );
186 tmp.mod_op = atoi( buf );
188 if ( tmp.mod_op == -1 || buf[0] == '\0' )
192 getline( buf, sizeof(buf), stdin, prompt2 );
193 if ( buf[0] == '\0' )
195 tmp.mod_type = strdup( buf );
197 tmp.mod_values = get_list( prompt3 );
199 if ( tmp.mod_values != NULL ) {
202 for ( i = 0; tmp.mod_values[i] != NULL; ++i )
204 bvals = (struct berval **)calloc( i + 1,
205 sizeof( struct berval *));
206 for ( i = 0; tmp.mod_values[i] != NULL; ++i ) {
207 bvals[i] = (struct berval *)malloc(
208 sizeof( struct berval ));
209 if ( strncmp( tmp.mod_values[i], "{FILE}",
211 if ( file_read( tmp.mod_values[i] + 6,
216 bvals[i]->bv_val = tmp.mod_values[i];
218 strlen( tmp.mod_values[i] );
221 tmp.mod_bvalues = bvals;
222 tmp.mod_op |= LDAP_MOD_BVALUES;
224 #endif /* MOD_USE_BVALS */
226 if ( result == NULL )
227 result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
229 result = (LDAPMod **) realloc( result,
230 sizeof(LDAPMod *) * (num + 1) );
232 result[num] = (LDAPMod *) malloc( sizeof(LDAPMod) );
233 *(result[num]) = tmp; /* struct copy */
236 if ( result == NULL )
238 result = (LDAPMod **) realloc( result, sizeof(LDAPMod *) * (num + 1) );
245 #ifdef LDAP_REFERRALS
247 bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
250 static char dn[256], passwd[256];
254 getline( dn, sizeof(dn), stdin,
255 "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
256 if (( *authmethodp = atoi( dn )) == 3 ) {
257 *authmethodp = LDAP_AUTH_KRBV4;
259 *authmethodp |= 0x80;
262 *authmethodp = LDAP_AUTH_SIMPLE;
263 #endif /* KERBEROS */
265 getline( dn, sizeof(dn), stdin, "re-bind dn? " );
266 strcat( dn, dnsuffix );
269 if ( *authmethodp == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) {
270 getline( passwd, sizeof(passwd), stdin,
271 "re-bind password? " );
278 return( LDAP_SUCCESS );
280 #endif /* LDAP_REFERRALS */
289 int argc, char **argv )
292 int i, c, port, cldapflg, errflg, method, id, msgtype;
293 char line[256], command1, command2, command3;
294 char passwd[64], dn[256], rdn[64], attr[64], value[256];
295 char filter[256], *host, **types;
297 char *usage = "usage: %s [-u] [-h host] [-d level] [-s dnsuffix] [-p port] [-t file] [-T file]\n";
298 int bound, all, scope, attrsonly;
300 LDAPMod **mods, **attrs;
301 struct timeval timeout;
302 char *copyfname = NULL;
310 if (( argv = get_list( "cmd line arg?" )) == NULL ) {
313 for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
321 cldapflg = errflg = 0;
323 while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
329 printf( "Compile with -DCLDAP for UDP support\n" );
335 ldap_debug = atoi( optarg );
336 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
337 lber_debug = ldap_debug;
340 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
353 port = atoi( optarg );
356 #if !defined(MACOS) && !defined(DOS)
357 case 't': /* copy ber's to given file */
358 copyfname = strdup( optarg );
359 copyoptions = LBER_TO_FILE;
362 case 'T': /* only output ber's to given file */
363 copyfname = strdup( optarg );
364 copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
373 if ( host == NULL && optind == argc - 1 ) {
374 host = argv[ optind ];
378 if ( errflg || optind < argc - 1 ) {
379 fprintf( stderr, usage, argv[ 0 ] );
383 printf( "%sldap_open( %s, %d )\n", cldapflg ? "c" : "",
384 host == NULL ? "(null)" : host, port );
388 ld = cldap_open( host, port );
391 ld = ldap_open( host, port );
395 perror( "ldap_open" );
399 #if !defined(MACOS) && !defined(DOS)
400 if ( copyfname != NULL ) {
401 if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
406 ld->ld_sb.sb_options = copyoptions;
414 (void) memset( line, '\0', sizeof(line) );
415 while ( getline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) {
420 switch ( command1 ) {
421 case 'a': /* add or abandon */
422 switch ( command2 ) {
424 getline( dn, sizeof(dn), stdin, "dn? " );
425 strcat( dn, dnsuffix );
426 if ( (attrs = get_modlist( NULL, "attr? ",
427 "value? " )) == NULL )
429 if ( (id = ldap_add( ld, dn, attrs )) == -1 )
430 ldap_perror( ld, "ldap_add" );
432 printf( "Add initiated with id %d\n",
436 case 'b': /* abandon */
437 getline( line, sizeof(line), stdin, "msgid? " );
439 if ( ldap_abandon( ld, id ) != 0 )
440 ldap_perror( ld, "ldap_abandon" );
442 printf( "Abandon successful\n" );
445 printf( "Possibilities: [ad]d, [ab]ort\n" );
449 case 'b': /* asynch bind */
451 getline( line, sizeof(line), stdin,
452 "method (0->simple, 1->krbv41, 2->krbv42)? " );
453 method = atoi( line ) | 0x80;
455 method = LDAP_AUTH_SIMPLE;
456 #endif /* KERBEROS */
457 getline( dn, sizeof(dn), stdin, "dn? " );
458 strcat( dn, dnsuffix );
460 if ( method == LDAP_AUTH_SIMPLE && dn[0] != '\0' )
461 getline( passwd, sizeof(passwd), stdin,
466 if ( ldap_bind( ld, dn, passwd, method ) == -1 ) {
467 fprintf( stderr, "ldap_bind failed\n" );
468 ldap_perror( ld, "ldap_bind" );
470 printf( "Bind initiated\n" );
475 case 'B': /* synch bind */
477 getline( line, sizeof(line), stdin,
478 "method 0->simple 1->krbv41 2->krbv42 3->krb? " );
479 method = atoi( line );
481 method = LDAP_AUTH_KRBV4;
483 method = method | 0x80;
485 method = LDAP_AUTH_SIMPLE;
486 #endif /* KERBEROS */
487 getline( dn, sizeof(dn), stdin, "dn? " );
488 strcat( dn, dnsuffix );
491 getline( passwd, sizeof(passwd), stdin,
496 if ( ldap_bind_s( ld, dn, passwd, method ) !=
498 fprintf( stderr, "ldap_bind_s failed\n" );
499 ldap_perror( ld, "ldap_bind_s" );
501 printf( "Bind successful\n" );
506 case 'c': /* compare */
507 getline( dn, sizeof(dn), stdin, "dn? " );
508 strcat( dn, dnsuffix );
509 getline( attr, sizeof(attr), stdin, "attr? " );
510 getline( value, sizeof(value), stdin, "value? " );
512 if ( (id = ldap_compare( ld, dn, attr, value )) == -1 )
513 ldap_perror( ld, "ldap_compare" );
515 printf( "Compare initiated with id %d\n", id );
518 case 'd': /* turn on debugging */
520 getline( line, sizeof(line), stdin, "debug level? " );
521 ldap_debug = atoi( line );
522 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
523 lber_debug = ldap_debug;
526 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
530 case 'E': /* explode a dn */
531 getline( line, sizeof(line), stdin, "dn? " );
532 exdn = ldap_explode_dn( line, 0 );
533 for ( i = 0; exdn != NULL && exdn[i] != NULL; i++ ) {
534 printf( "\t%s\n", exdn[i] );
538 case 'g': /* set next msgid */
539 getline( line, sizeof(line), stdin, "msgid? " );
540 ld->ld_msgid = atoi( line );
543 case 'v': /* set version number */
544 getline( line, sizeof(line), stdin, "version? " );
545 ld->ld_version = atoi( line );
548 case 'm': /* modify or modifyrdn */
549 if ( strncmp( line, "modify", 4 ) == 0 ) {
550 getline( dn, sizeof(dn), stdin, "dn? " );
551 strcat( dn, dnsuffix );
552 if ( (mods = get_modlist(
553 "mod (0=>add, 1=>delete, 2=>replace -1=>done)? ",
554 "attribute type? ", "attribute value? " ))
557 if ( (id = ldap_modify( ld, dn, mods )) == -1 )
558 ldap_perror( ld, "ldap_modify" );
560 printf( "Modify initiated with id %d\n",
562 } else if ( strncmp( line, "modrdn", 4 ) == 0 ) {
563 getline( dn, sizeof(dn), stdin, "dn? " );
564 strcat( dn, dnsuffix );
565 getline( rdn, sizeof(rdn), stdin, "newrdn? " );
566 if ( (id = ldap_modrdn( ld, dn, rdn )) == -1 )
567 ldap_perror( ld, "ldap_modrdn" );
569 printf( "Modrdn initiated with id %d\n",
572 printf( "Possibilities: [modi]fy, [modr]dn\n" );
581 #ifdef LDAP_REFERRALS
583 #else /* LDAP_REFERRALS */
584 if ( !cldapflg && bound )
585 #endif /* LDAP_REFERRALS */
590 case 'r': /* result or remove */
591 switch ( command3 ) {
592 case 's': /* result */
593 getline( line, sizeof(line), stdin,
594 "msgid (-1=>any)? " );
595 if ( line[0] == '\0' )
599 getline( line, sizeof(line), stdin,
600 "all (0=>any, 1=>all)? " );
601 if ( line[0] == '\0' )
605 if (( msgtype = ldap_result( ld, id, all,
606 &timeout, &res )) < 1 ) {
607 ldap_perror( ld, "ldap_result" );
610 printf( "\nresult: msgtype %d msgid %d\n",
611 msgtype, res->lm_msgid );
612 handle_result( ld, res );
616 case 'm': /* remove */
617 getline( dn, sizeof(dn), stdin, "dn? " );
618 strcat( dn, dnsuffix );
619 if ( (id = ldap_delete( ld, dn )) == -1 )
620 ldap_perror( ld, "ldap_delete" );
622 printf( "Remove initiated with id %d\n",
627 printf( "Possibilities: [rem]ove, [res]ult\n" );
632 case 's': /* search */
633 getline( dn, sizeof(dn), stdin, "searchbase? " );
634 strcat( dn, dnsuffix );
635 getline( line, sizeof(line), stdin,
636 "scope (0=Base, 1=One Level, 2=Subtree)? " );
637 scope = atoi( line );
638 getline( filter, sizeof(filter), stdin,
639 "search filter (e.g. sn=jones)? " );
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 );
647 getline( line, sizeof(line), stdin,
648 "Requestor DN (for logging)? " );
649 if ( cldap_search_s( ld, dn, scope, filter, types,
650 attrsonly, &res, line ) != 0 ) {
651 ldap_perror( ld, "cldap_search_s" );
653 printf( "\nresult: msgid %d\n",
655 handle_result( ld, res );
660 if (( id = ldap_search( ld, dn, scope, filter,
661 types, attrsonly )) == -1 ) {
662 ldap_perror( ld, "ldap_search" );
664 printf( "Search initiated with id %d\n", id );
670 case 't': /* set timeout value */
671 getline( line, sizeof(line), stdin, "timeout? " );
672 timeout.tv_sec = atoi( line );
675 case 'U': /* set ufn search prefix */
676 getline( line, sizeof(line), stdin, "ufn prefix? " );
677 ldap_ufn_setprefix( ld, line );
680 case 'u': /* user friendly search w/optional timeout */
681 getline( dn, sizeof(dn), stdin, "ufn? " );
682 strcat( dn, dnsuffix );
683 types = get_list( "attrs to return? " );
684 getline( line, sizeof(line), stdin,
685 "attrsonly (0=attrs&values, 1=attrs only)? " );
686 attrsonly = atoi( line );
688 if ( command2 == 't' ) {
689 id = ldap_ufn_search_c( ld, dn, types,
690 attrsonly, &res, ldap_ufn_timeout,
693 id = ldap_ufn_search_s( ld, dn, types,
697 ldap_perror( ld, "ldap_ufn_search" );
699 printf( "\nresult: err %d\n", id );
700 handle_result( ld, res );
706 case 'l': /* URL search */
707 getline( line, sizeof(line), stdin,
708 "attrsonly (0=attrs&values, 1=attrs only)? " );
709 attrsonly = atoi( line );
710 getline( line, sizeof(line), stdin, "LDAP URL? " );
711 if (( id = ldap_url_search( ld, line, attrsonly ))
713 ldap_perror( ld, "ldap_url_search" );
715 printf( "URL search initiated with id %d\n", id );
719 case 'p': /* parse LDAP URL */
720 getline( line, sizeof(line), stdin, "LDAP URL? " );
721 if (( i = ldap_url_parse( line, &ludp )) != 0 ) {
722 fprintf( stderr, "ldap_url_parse: error %d\n", i );
724 printf( "\t host: " );
725 if ( ludp->lud_host == NULL ) {
726 printf( "DEFAULT\n" );
728 printf( "<%s>\n", ludp->lud_host );
730 printf( "\t port: " );
731 if ( ludp->lud_port == 0 ) {
732 printf( "DEFAULT\n" );
734 printf( "%d\n", ludp->lud_port );
736 printf( "\t dn: <%s>\n", ludp->lud_dn );
737 printf( "\t attrs:" );
738 if ( ludp->lud_attrs == NULL ) {
741 for ( i = 0; ludp->lud_attrs[ i ] != NULL; ++i ) {
742 printf( " <%s>", ludp->lud_attrs[ i ] );
745 printf( "\n\t scope: %s\n", ludp->lud_scope == LDAP_SCOPE_ONELEVEL ?
746 "ONE" : ludp->lud_scope == LDAP_SCOPE_BASE ? "BASE" :
747 ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
748 printf( "\tfilter: <%s>\n", ludp->lud_filter );
749 ldap_free_urldesc( ludp );
753 case 'n': /* set dn suffix, for convenience */
754 getline( line, sizeof(line), stdin, "DN suffix? " );
755 strcpy( dnsuffix, line );
758 case 'e': /* enable cache */
760 printf( NOCACHEERRMSG );
762 getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
764 getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
765 if ( ldap_enable_cache( ld, i, atoi( line )) == 0 ) {
766 printf( "local cache is on\n" );
768 printf( "ldap_enable_cache failed\n" );
770 #endif /* NO_CACHE */
773 case 'x': /* uncache entry */
775 printf( NOCACHEERRMSG );
777 getline( line, sizeof(line), stdin, "DN? " );
778 ldap_uncache_entry( ld, line );
779 #endif /* NO_CACHE */
782 case 'X': /* uncache request */
784 printf( NOCACHEERRMSG );
786 getline( line, sizeof(line), stdin, "request msgid? " );
787 ldap_uncache_request( ld, atoi( line ));
788 #endif /* NO_CACHE */
791 case 'o': /* set ldap options */
792 getline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" );
793 ld->ld_deref = atoi( line );
794 getline( line, sizeof(line), stdin, "timelimit?" );
795 ld->ld_timelimit = atoi( line );
796 getline( line, sizeof(line), stdin, "sizelimit?" );
797 ld->ld_sizelimit = atoi( line );
801 #ifdef STR_TRANSLATION
802 getline( line, sizeof(line), stdin,
803 "Automatic translation of T.61 strings (0=no, 1=yes)?" );
804 if ( atoi( line ) == 0 ) {
805 ld->ld_lberoptions &= ~LBER_TRANSLATE_STRINGS;
807 ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS;
808 #ifdef LDAP_CHARSET_8859
809 getline( line, sizeof(line), stdin,
810 "Translate to/from ISO-8859 (0=no, 1=yes?" );
811 if ( atoi( line ) != 0 ) {
812 ldap_set_string_translators( ld,
816 #endif /* LDAP_CHARSET_8859 */
818 #endif /* STR_TRANSLATION */
821 getline( line, sizeof(line), stdin,
822 "Use DN & DNS to determine where to send requests (0=no, 1=yes)?" );
823 if ( atoi( line ) != 0 ) {
824 ld->ld_options |= LDAP_OPT_DNS;
826 #endif /* LDAP_DNS */
828 #ifdef LDAP_REFERRALS
829 getline( line, sizeof(line), stdin,
830 "Recognize and chase referrals (0=no, 1=yes)?" );
831 if ( atoi( line ) != 0 ) {
832 ld->ld_options |= LDAP_OPT_REFERRALS;
833 getline( line, sizeof(line), stdin,
834 "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" );
835 if ( atoi( line ) != 0 ) {
836 ldap_set_rebind_proc( ld, bind_prompt );
839 #endif /* LDAP_REFERRALS */
842 case 'O': /* set cache options */
844 printf( NOCACHEERRMSG );
846 getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
847 switch( atoi( line )) {
849 ldap_set_cache_options( ld, 0 );
852 ldap_set_cache_options( ld,
853 LDAP_CACHE_OPT_CACHENOERRS );
856 ldap_set_cache_options( ld,
857 LDAP_CACHE_OPT_CACHEALLERRS );
860 printf( "not a valid cache option\n" );
862 #endif /* NO_CACHE */
866 printf( "Commands: [ad]d [ab]andon [b]ind\n" );
867 printf( " [B]ind async [c]ompare [l]URL search\n" );
868 printf( " [modi]fy [modr]dn [rem]ove\n" );
869 printf( " [res]ult [s]earch [q]uit/unbind\n\n" );
870 printf( " [u]fn search [ut]fn search with timeout\n" );
871 printf( " [d]ebug [e]nable cache set ms[g]id\n" );
872 printf( " d[n]suffix [t]imeout [v]ersion\n" );
873 printf( " [U]fn prefix [x]uncache entry [X]uncache request\n" );
874 printf( " [?]help [o]ptions [O]cache options\n" );
875 printf( " [E]xplode dn [p]arse LDAP URL\n" );
879 printf( "Invalid command. Type ? for help.\n" );
883 (void) memset( line, '\0', sizeof(line) );
890 handle_result( LDAP *ld, LDAPMessage *lm )
892 switch ( lm->lm_msgtype ) {
893 case LDAP_RES_COMPARE:
894 printf( "Compare result\n" );
895 print_ldap_result( ld, lm, "compare" );
898 case LDAP_RES_SEARCH_RESULT:
899 printf( "Search result\n" );
900 print_ldap_result( ld, lm, "search" );
903 case LDAP_RES_SEARCH_ENTRY:
904 printf( "Search entry\n" );
905 print_search_entry( ld, lm );
909 printf( "Add result\n" );
910 print_ldap_result( ld, lm, "add" );
913 case LDAP_RES_DELETE:
914 printf( "Delete result\n" );
915 print_ldap_result( ld, lm, "delete" );
918 case LDAP_RES_MODRDN:
919 printf( "ModRDN result\n" );
920 print_ldap_result( ld, lm, "modrdn" );
924 printf( "Bind result\n" );
925 print_ldap_result( ld, lm, "bind" );
929 printf( "Unknown result type 0x%x\n", lm->lm_msgtype );
930 print_ldap_result( ld, lm, "unknown" );
935 print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
937 ldap_result2error( ld, lm, 1 );
938 ldap_perror( ld, s );
940 if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
941 fprintf( stderr, "Additional info: %s\n", ld->ld_error );
942 if ( NAME_ERROR( ld->ld_errno ) && ld->ld_matched != NULL )
943 fprintf( stderr, "Matched DN: %s\n", ld->ld_matched );
948 print_search_entry( LDAP *ld, LDAPMessage *res )
952 struct berval **vals;
956 for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
957 e = ldap_next_entry( ld, e ) ) {
958 if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
961 dn = ldap_get_dn( ld, e );
962 printf( "\tDN: %s\n", dn );
964 ufn = ldap_dn2ufn( dn );
965 printf( "\tUFN: %s\n", ufn );
974 for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
975 a = ldap_next_attribute( ld, e, ber ) ) {
976 printf( "\t\tATTR: %s\n", a );
977 if ( (vals = ldap_get_values_len( ld, e, a ))
979 printf( "\t\t\t(no values)\n" );
981 for ( i = 0; vals[i] != NULL; i++ ) {
985 for ( j = 0; j < vals[i]->bv_len; j++ )
986 if ( !isascii( vals[i]->bv_val[j] ) ) {
992 printf( "\t\t\tlength (%ld) (not ascii)\n", vals[i]->bv_len );
993 #ifdef BPRINT_NONASCII
994 lber_bprint( vals[i]->bv_val,
996 #endif /* BPRINT_NONASCII */
999 printf( "\t\t\tlength (%ld) %s\n",
1000 vals[i]->bv_len, vals[i]->bv_val );
1002 ber_bvecfree( vals );
1007 if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT
1008 || res->lm_chain != NULLMSG )
1009 print_ldap_result( ld, res, "search" );
1015 ldap_perror( LDAP *ld, char *s )
1024 errs = ldap_err2string( ld->ld_errno );
1025 printf( "%s: %s\n", s, errs == NULL ? "unknown error" : errs );
1026 if ( ld->ld_error != NULL && *ld->ld_error != '\0' ) {
1027 printf( "%s: additional info: %s\n", s, ld->ld_error );
1030 #endif /* WINSOCK */