13 #if defined( DOS ) || defined( _WIN32 )
15 #if defined( WINSOCK ) || defined( _WIN32 )
19 #include <sys/types.h>
20 #include <sys/socket.h>
34 #if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS )
36 #endif /* !PCNFS && !WINSOCK && !MACOS */
39 static void handle_result( LDAP *ld, LDAPMessage *lm );
40 static void print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s );
41 static void print_search_entry( LDAP *ld, LDAPMessage *res );
42 static void free_list( char **list );
44 static void handle_result();
45 static void print_ldap_result();
46 static void print_search_entry();
47 static void free_list();
48 #endif /* NEEDPROTOS */
50 #define NOCACHEERRMSG "don't compile with -DNO_CACHE if you desire local caching"
56 getline( char *line, int len, FILE *fp, char *prompt )
60 if ( fgets( line, len, fp ) == NULL )
63 line[ strlen( line ) - 1 ] = '\0';
70 get_list( char *prompt )
79 getline( buf, sizeof(buf), stdin, prompt );
84 if ( result == (char **) 0 )
85 result = (char **) malloc( sizeof(char *) );
87 result = (char **) realloc( result,
88 sizeof(char *) * (num + 1) );
90 result[num++] = (char *) strdup( buf );
92 if ( result == (char **) 0 )
94 result = (char **) realloc( result, sizeof(char *) * (num + 1) );
102 free_list( char **list )
106 if ( list != NULL ) {
107 for ( i = 0; list[ i ] != NULL; ++i ) {
110 free( (char *)list );
117 file_read( char *path, struct berval *bv )
123 if (( fp = fopen( path, "r" )) == NULL ) {
128 if ( fseek( fp, 0L, SEEK_END ) != 0 ) {
134 bv->bv_len = ftell( fp );
136 if (( bv->bv_val = (char *)malloc( bv->bv_len )) == NULL ) {
142 if ( fseek( fp, 0L, SEEK_SET ) != 0 ) {
148 rlen = fread( bv->bv_val, 1, bv->bv_len, fp );
152 if ( rlen != bv->bv_len ) {
158 return( bv->bv_len );
160 #endif /* MOD_USE_BVALS */
164 get_modlist( char *prompt1, char *prompt2, char *prompt3 )
166 static char buf[256];
171 struct berval **bvals;
172 #endif /* MOD_USE_BVALS */
178 getline( buf, sizeof(buf), stdin, prompt1 );
179 tmp.mod_op = atoi( buf );
181 if ( tmp.mod_op == -1 || buf[0] == '\0' )
185 getline( buf, sizeof(buf), stdin, prompt2 );
186 if ( buf[0] == '\0' )
188 tmp.mod_type = strdup( buf );
190 tmp.mod_values = get_list( prompt3 );
192 if ( tmp.mod_values != NULL ) {
195 for ( i = 0; tmp.mod_values[i] != NULL; ++i )
197 bvals = (struct berval **)calloc( i + 1,
198 sizeof( struct berval *));
199 for ( i = 0; tmp.mod_values[i] != NULL; ++i ) {
200 bvals[i] = (struct berval *)malloc(
201 sizeof( struct berval ));
202 if ( strncmp( tmp.mod_values[i], "{FILE}",
204 if ( file_read( tmp.mod_values[i] + 6,
209 bvals[i]->bv_val = tmp.mod_values[i];
211 strlen( tmp.mod_values[i] );
214 tmp.mod_bvalues = bvals;
215 tmp.mod_op |= LDAP_MOD_BVALUES;
217 #endif /* MOD_USE_BVALS */
219 if ( result == NULL )
220 result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
222 result = (LDAPMod **) realloc( result,
223 sizeof(LDAPMod *) * (num + 1) );
225 result[num] = (LDAPMod *) malloc( sizeof(LDAPMod) );
226 *(result[num]) = tmp; /* struct copy */
229 if ( result == NULL )
231 result = (LDAPMod **) realloc( result, sizeof(LDAPMod *) * (num + 1) );
238 #ifdef LDAP_REFERRALS
240 bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
243 static char dn[256], passwd[256];
247 getline( dn, sizeof(dn), stdin,
248 "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
249 if (( *authmethodp = atoi( dn )) == 3 ) {
250 *authmethodp = LDAP_AUTH_KRBV4;
252 *authmethodp |= 0x80;
255 *authmethodp = LDAP_AUTH_SIMPLE;
256 #endif /* KERBEROS */
258 getline( dn, sizeof(dn), stdin, "re-bind dn? " );
259 strcat( dn, dnsuffix );
262 if ( *authmethodp == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) {
263 getline( passwd, sizeof(passwd), stdin,
264 "re-bind password? " );
271 return( LDAP_SUCCESS );
273 #endif /* LDAP_REFERRALS */
282 int argc, char **argv )
285 int i, c, port, cldapflg, errflg, method, id, msgtype;
286 char line[256], command1, command2, command3;
287 char passwd[64], dn[256], rdn[64], attr[64], value[256];
288 char filter[256], *host, **types;
290 char *usage = "usage: %s [-u] [-h host] [-d level] [-s dnsuffix] [-p port] [-t file] [-T file]\n";
291 int bound, all, scope, attrsonly;
293 LDAPMod **mods, **attrs;
294 struct timeval timeout;
295 char *copyfname = NULL;
303 if (( argv = get_list( "cmd line arg?" )) == NULL ) {
306 for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
314 cldapflg = errflg = 0;
316 while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
322 printf( "Compile with -DCLDAP for UDP support\n" );
328 ldap_debug = atoi( optarg );
329 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
330 lber_debug = ldap_debug;
333 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
346 port = atoi( optarg );
349 #if !defined(MACOS) && !defined(DOS)
350 case 't': /* copy ber's to given file */
351 copyfname = strdup( optarg );
352 copyoptions = LBER_TO_FILE;
355 case 'T': /* only output ber's to given file */
356 copyfname = strdup( optarg );
357 copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
366 if ( host == NULL && optind == argc - 1 ) {
367 host = argv[ optind ];
371 if ( errflg || optind < argc - 1 ) {
372 fprintf( stderr, usage, argv[ 0 ] );
376 printf( "%sldap_open( %s, %d )\n", cldapflg ? "c" : "",
377 host == NULL ? "(null)" : host, port );
381 ld = cldap_open( host, port );
384 ld = ldap_open( host, port );
388 perror( "ldap_open" );
392 #if !defined(MACOS) && !defined(DOS)
393 if ( copyfname != NULL ) {
394 if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
399 ld->ld_sb.sb_options = copyoptions;
407 (void) memset( line, '\0', sizeof(line) );
408 while ( getline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) {
413 switch ( command1 ) {
414 case 'a': /* add or abandon */
415 switch ( command2 ) {
417 getline( dn, sizeof(dn), stdin, "dn? " );
418 strcat( dn, dnsuffix );
419 if ( (attrs = get_modlist( NULL, "attr? ",
420 "value? " )) == NULL )
422 if ( (id = ldap_add( ld, dn, attrs )) == -1 )
423 ldap_perror( ld, "ldap_add" );
425 printf( "Add initiated with id %d\n",
429 case 'b': /* abandon */
430 getline( line, sizeof(line), stdin, "msgid? " );
432 if ( ldap_abandon( ld, id ) != 0 )
433 ldap_perror( ld, "ldap_abandon" );
435 printf( "Abandon successful\n" );
438 printf( "Possibilities: [ad]d, [ab]ort\n" );
442 case 'b': /* asynch bind */
444 getline( line, sizeof(line), stdin,
445 "method (0->simple, 1->krbv41, 2->krbv42)? " );
446 method = atoi( line ) | 0x80;
448 method = LDAP_AUTH_SIMPLE;
449 #endif /* KERBEROS */
450 getline( dn, sizeof(dn), stdin, "dn? " );
451 strcat( dn, dnsuffix );
453 if ( method == LDAP_AUTH_SIMPLE && dn[0] != '\0' )
454 getline( passwd, sizeof(passwd), stdin,
459 if ( ldap_bind( ld, dn, passwd, method ) == -1 ) {
460 fprintf( stderr, "ldap_bind failed\n" );
461 ldap_perror( ld, "ldap_bind" );
463 printf( "Bind initiated\n" );
468 case 'B': /* synch bind */
470 getline( line, sizeof(line), stdin,
471 "method 0->simple 1->krbv41 2->krbv42 3->krb? " );
472 method = atoi( line );
474 method = LDAP_AUTH_KRBV4;
476 method = method | 0x80;
478 method = LDAP_AUTH_SIMPLE;
479 #endif /* KERBEROS */
480 getline( dn, sizeof(dn), stdin, "dn? " );
481 strcat( dn, dnsuffix );
484 getline( passwd, sizeof(passwd), stdin,
489 if ( ldap_bind_s( ld, dn, passwd, method ) !=
491 fprintf( stderr, "ldap_bind_s failed\n" );
492 ldap_perror( ld, "ldap_bind_s" );
494 printf( "Bind successful\n" );
499 case 'c': /* compare */
500 getline( dn, sizeof(dn), stdin, "dn? " );
501 strcat( dn, dnsuffix );
502 getline( attr, sizeof(attr), stdin, "attr? " );
503 getline( value, sizeof(value), stdin, "value? " );
505 if ( (id = ldap_compare( ld, dn, attr, value )) == -1 )
506 ldap_perror( ld, "ldap_compare" );
508 printf( "Compare initiated with id %d\n", id );
511 case 'd': /* turn on debugging */
513 getline( line, sizeof(line), stdin, "debug level? " );
514 ldap_debug = atoi( line );
515 if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
516 lber_debug = ldap_debug;
519 printf( "Compile with -DLDAP_DEBUG for debugging\n" );
523 case 'E': /* explode a dn */
524 getline( line, sizeof(line), stdin, "dn? " );
525 exdn = ldap_explode_dn( line, 0 );
526 for ( i = 0; exdn != NULL && exdn[i] != NULL; i++ ) {
527 printf( "\t%s\n", exdn[i] );
531 case 'g': /* set next msgid */
532 getline( line, sizeof(line), stdin, "msgid? " );
533 ld->ld_msgid = atoi( line );
536 case 'v': /* set version number */
537 getline( line, sizeof(line), stdin, "version? " );
538 ld->ld_version = atoi( line );
541 case 'm': /* modify or modifyrdn */
542 if ( strncmp( line, "modify", 4 ) == 0 ) {
543 getline( dn, sizeof(dn), stdin, "dn? " );
544 strcat( dn, dnsuffix );
545 if ( (mods = get_modlist(
546 "mod (0=>add, 1=>delete, 2=>replace -1=>done)? ",
547 "attribute type? ", "attribute value? " ))
550 if ( (id = ldap_modify( ld, dn, mods )) == -1 )
551 ldap_perror( ld, "ldap_modify" );
553 printf( "Modify initiated with id %d\n",
555 } else if ( strncmp( line, "modrdn", 4 ) == 0 ) {
556 getline( dn, sizeof(dn), stdin, "dn? " );
557 strcat( dn, dnsuffix );
558 getline( rdn, sizeof(rdn), stdin, "newrdn? " );
559 if ( (id = ldap_modrdn( ld, dn, rdn )) == -1 )
560 ldap_perror( ld, "ldap_modrdn" );
562 printf( "Modrdn initiated with id %d\n",
565 printf( "Possibilities: [modi]fy, [modr]dn\n" );
574 #ifdef LDAP_REFERRALS
576 #else /* LDAP_REFERRALS */
577 if ( !cldapflg && bound )
578 #endif /* LDAP_REFERRALS */
583 case 'r': /* result or remove */
584 switch ( command3 ) {
585 case 's': /* result */
586 getline( line, sizeof(line), stdin,
587 "msgid (-1=>any)? " );
588 if ( line[0] == '\0' )
592 getline( line, sizeof(line), stdin,
593 "all (0=>any, 1=>all)? " );
594 if ( line[0] == '\0' )
598 if (( msgtype = ldap_result( ld, id, all,
599 &timeout, &res )) < 1 ) {
600 ldap_perror( ld, "ldap_result" );
603 printf( "\nresult: msgtype %d msgid %d\n",
604 msgtype, res->lm_msgid );
605 handle_result( ld, res );
609 case 'm': /* remove */
610 getline( dn, sizeof(dn), stdin, "dn? " );
611 strcat( dn, dnsuffix );
612 if ( (id = ldap_delete( ld, dn )) == -1 )
613 ldap_perror( ld, "ldap_delete" );
615 printf( "Remove initiated with id %d\n",
620 printf( "Possibilities: [rem]ove, [res]ult\n" );
625 case 's': /* search */
626 getline( dn, sizeof(dn), stdin, "searchbase? " );
627 strcat( dn, dnsuffix );
628 getline( line, sizeof(line), stdin,
629 "scope (0=Base, 1=One Level, 2=Subtree)? " );
630 scope = atoi( line );
631 getline( filter, sizeof(filter), stdin,
632 "search filter (e.g. sn=jones)? " );
633 types = get_list( "attrs to return? " );
634 getline( line, sizeof(line), stdin,
635 "attrsonly (0=attrs&values, 1=attrs only)? " );
636 attrsonly = atoi( line );
640 getline( line, sizeof(line), stdin,
641 "Requestor DN (for logging)? " );
642 if ( cldap_search_s( ld, dn, scope, filter, types,
643 attrsonly, &res, line ) != 0 ) {
644 ldap_perror( ld, "cldap_search_s" );
646 printf( "\nresult: msgid %d\n",
648 handle_result( ld, res );
653 if (( id = ldap_search( ld, dn, scope, filter,
654 types, attrsonly )) == -1 ) {
655 ldap_perror( ld, "ldap_search" );
657 printf( "Search initiated with id %d\n", id );
663 case 't': /* set timeout value */
664 getline( line, sizeof(line), stdin, "timeout? " );
665 timeout.tv_sec = atoi( line );
668 case 'U': /* set ufn search prefix */
669 getline( line, sizeof(line), stdin, "ufn prefix? " );
670 ldap_ufn_setprefix( ld, line );
673 case 'u': /* user friendly search w/optional timeout */
674 getline( dn, sizeof(dn), stdin, "ufn? " );
675 strcat( dn, dnsuffix );
676 types = get_list( "attrs to return? " );
677 getline( line, sizeof(line), stdin,
678 "attrsonly (0=attrs&values, 1=attrs only)? " );
679 attrsonly = atoi( line );
681 if ( command2 == 't' ) {
682 id = ldap_ufn_search_c( ld, dn, types,
683 attrsonly, &res, ldap_ufn_timeout,
686 id = ldap_ufn_search_s( ld, dn, types,
690 ldap_perror( ld, "ldap_ufn_search" );
692 printf( "\nresult: err %d\n", id );
693 handle_result( ld, res );
699 case 'l': /* URL search */
700 getline( line, sizeof(line), stdin,
701 "attrsonly (0=attrs&values, 1=attrs only)? " );
702 attrsonly = atoi( line );
703 getline( line, sizeof(line), stdin, "LDAP URL? " );
704 if (( id = ldap_url_search( ld, line, attrsonly ))
706 ldap_perror( ld, "ldap_url_search" );
708 printf( "URL search initiated with id %d\n", id );
712 case 'p': /* parse LDAP URL */
713 getline( line, sizeof(line), stdin, "LDAP URL? " );
714 if (( i = ldap_url_parse( line, &ludp )) != 0 ) {
715 fprintf( stderr, "ldap_url_parse: error %d\n", i );
717 printf( "\t host: " );
718 if ( ludp->lud_host == NULL ) {
719 printf( "DEFAULT\n" );
721 printf( "<%s>\n", ludp->lud_host );
723 printf( "\t port: " );
724 if ( ludp->lud_port == 0 ) {
725 printf( "DEFAULT\n" );
727 printf( "%d\n", ludp->lud_port );
729 printf( "\t dn: <%s>\n", ludp->lud_dn );
730 printf( "\t attrs:" );
731 if ( ludp->lud_attrs == NULL ) {
734 for ( i = 0; ludp->lud_attrs[ i ] != NULL; ++i ) {
735 printf( " <%s>", ludp->lud_attrs[ i ] );
738 printf( "\n\t scope: %s\n", ludp->lud_scope == LDAP_SCOPE_ONELEVEL ?
739 "ONE" : ludp->lud_scope == LDAP_SCOPE_BASE ? "BASE" :
740 ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
741 printf( "\tfilter: <%s>\n", ludp->lud_filter );
742 ldap_free_urldesc( ludp );
746 case 'n': /* set dn suffix, for convenience */
747 getline( line, sizeof(line), stdin, "DN suffix? " );
748 strcpy( dnsuffix, line );
751 case 'e': /* enable cache */
753 printf( NOCACHEERRMSG );
755 getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
757 getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
758 if ( ldap_enable_cache( ld, i, atoi( line )) == 0 ) {
759 printf( "local cache is on\n" );
761 printf( "ldap_enable_cache failed\n" );
763 #endif /* NO_CACHE */
766 case 'x': /* uncache entry */
768 printf( NOCACHEERRMSG );
770 getline( line, sizeof(line), stdin, "DN? " );
771 ldap_uncache_entry( ld, line );
772 #endif /* NO_CACHE */
775 case 'X': /* uncache request */
777 printf( NOCACHEERRMSG );
779 getline( line, sizeof(line), stdin, "request msgid? " );
780 ldap_uncache_request( ld, atoi( line ));
781 #endif /* NO_CACHE */
784 case 'o': /* set ldap options */
785 getline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" );
786 ld->ld_deref = atoi( line );
787 getline( line, sizeof(line), stdin, "timelimit?" );
788 ld->ld_timelimit = atoi( line );
789 getline( line, sizeof(line), stdin, "sizelimit?" );
790 ld->ld_sizelimit = atoi( line );
794 #ifdef STR_TRANSLATION
795 getline( line, sizeof(line), stdin,
796 "Automatic translation of T.61 strings (0=no, 1=yes)?" );
797 if ( atoi( line ) == 0 ) {
798 ld->ld_lberoptions &= ~LBER_TRANSLATE_STRINGS;
800 ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS;
801 #ifdef LDAP_CHARSET_8859
802 getline( line, sizeof(line), stdin,
803 "Translate to/from ISO-8859 (0=no, 1=yes?" );
804 if ( atoi( line ) != 0 ) {
805 ldap_set_string_translators( ld,
809 #endif /* LDAP_CHARSET_8859 */
811 #endif /* STR_TRANSLATION */
814 getline( line, sizeof(line), stdin,
815 "Use DN & DNS to determine where to send requests (0=no, 1=yes)?" );
816 if ( atoi( line ) != 0 ) {
817 ld->ld_options |= LDAP_OPT_DNS;
819 #endif /* LDAP_DNS */
821 #ifdef LDAP_REFERRALS
822 getline( line, sizeof(line), stdin,
823 "Recognize and chase referrals (0=no, 1=yes)?" );
824 if ( atoi( line ) != 0 ) {
825 ld->ld_options |= LDAP_OPT_REFERRALS;
826 getline( line, sizeof(line), stdin,
827 "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" );
828 if ( atoi( line ) != 0 ) {
829 ldap_set_rebind_proc( ld, bind_prompt );
832 #endif /* LDAP_REFERRALS */
835 case 'O': /* set cache options */
837 printf( NOCACHEERRMSG );
839 getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
840 switch( atoi( line )) {
842 ldap_set_cache_options( ld, 0 );
845 ldap_set_cache_options( ld,
846 LDAP_CACHE_OPT_CACHENOERRS );
849 ldap_set_cache_options( ld,
850 LDAP_CACHE_OPT_CACHEALLERRS );
853 printf( "not a valid cache option\n" );
855 #endif /* NO_CACHE */
859 printf( "Commands: [ad]d [ab]andon [b]ind\n" );
860 printf( " [B]ind async [c]ompare [l]URL search\n" );
861 printf( " [modi]fy [modr]dn [rem]ove\n" );
862 printf( " [res]ult [s]earch [q]uit/unbind\n\n" );
863 printf( " [u]fn search [ut]fn search with timeout\n" );
864 printf( " [d]ebug [e]nable cache set ms[g]id\n" );
865 printf( " d[n]suffix [t]imeout [v]ersion\n" );
866 printf( " [U]fn prefix [x]uncache entry [X]uncache request\n" );
867 printf( " [?]help [o]ptions [O]cache options\n" );
868 printf( " [E]xplode dn [p]arse LDAP URL\n" );
872 printf( "Invalid command. Type ? for help.\n" );
876 (void) memset( line, '\0', sizeof(line) );
883 handle_result( LDAP *ld, LDAPMessage *lm )
885 switch ( lm->lm_msgtype ) {
886 case LDAP_RES_COMPARE:
887 printf( "Compare result\n" );
888 print_ldap_result( ld, lm, "compare" );
891 case LDAP_RES_SEARCH_RESULT:
892 printf( "Search result\n" );
893 print_ldap_result( ld, lm, "search" );
896 case LDAP_RES_SEARCH_ENTRY:
897 printf( "Search entry\n" );
898 print_search_entry( ld, lm );
902 printf( "Add result\n" );
903 print_ldap_result( ld, lm, "add" );
906 case LDAP_RES_DELETE:
907 printf( "Delete result\n" );
908 print_ldap_result( ld, lm, "delete" );
911 case LDAP_RES_MODRDN:
912 printf( "ModRDN result\n" );
913 print_ldap_result( ld, lm, "modrdn" );
917 printf( "Bind result\n" );
918 print_ldap_result( ld, lm, "bind" );
922 printf( "Unknown result type 0x%x\n", lm->lm_msgtype );
923 print_ldap_result( ld, lm, "unknown" );
928 print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
930 ldap_result2error( ld, lm, 1 );
931 ldap_perror( ld, s );
933 if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
934 fprintf( stderr, "Additional info: %s\n", ld->ld_error );
935 if ( NAME_ERROR( ld->ld_errno ) && ld->ld_matched != NULL )
936 fprintf( stderr, "Matched DN: %s\n", ld->ld_matched );
941 print_search_entry( LDAP *ld, LDAPMessage *res )
945 struct berval **vals;
949 for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
950 e = ldap_next_entry( ld, e ) ) {
951 if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
954 dn = ldap_get_dn( ld, e );
955 printf( "\tDN: %s\n", dn );
957 ufn = ldap_dn2ufn( dn );
958 printf( "\tUFN: %s\n", ufn );
967 for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
968 a = ldap_next_attribute( ld, e, ber ) ) {
969 printf( "\t\tATTR: %s\n", a );
970 if ( (vals = ldap_get_values_len( ld, e, a ))
972 printf( "\t\t\t(no values)\n" );
974 for ( i = 0; vals[i] != NULL; i++ ) {
978 for ( j = 0; j < vals[i]->bv_len; j++ )
979 if ( !isascii( vals[i]->bv_val[j] ) ) {
985 printf( "\t\t\tlength (%ld) (not ascii)\n", vals[i]->bv_len );
986 #ifdef BPRINT_NONASCII
987 lber_bprint( vals[i]->bv_val,
989 #endif /* BPRINT_NONASCII */
992 printf( "\t\t\tlength (%ld) %s\n",
993 vals[i]->bv_len, vals[i]->bv_val );
995 ber_bvecfree( vals );
1000 if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT
1001 || res->lm_chain != NULLMSG )
1002 print_ldap_result( ld, res, "search" );
1008 ldap_perror( LDAP *ld, char *s )
1017 errs = ldap_err2string( ld->ld_errno );
1018 printf( "%s: %s\n", s, errs == NULL ? "unknown error" : errs );
1019 if ( ld->ld_error != NULL && *ld->ld_error != '\0' ) {
1020 printf( "%s: additional info: %s\n", s, ld->ld_error );
1023 #endif /* WINSOCK */