- for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
- if ( ld->ld_errno == ldap_errlist[i].e_code ) {
- fprintf( stderr, "%s: %s\n", s,
- ldap_errlist[i].e_reason );
- if ( ld->ld_matched != NULL && *ld->ld_matched != '\0' )
- fprintf( stderr, "%s: matched: %s\n", s,
- ld->ld_matched );
- if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
- fprintf( stderr, "%s: additional info: %s\n",
- s, ld->ld_error );
- fflush( stderr );
- return;
- }
+ e = ldap_int_error( ld->ld_errno );
+
+ if ( e != NULL ) {
+ fprintf( stderr, "%s: %s\n",
+ s, e->e_reason );
+ } else {
+ fprintf( stderr, "%s: unknown LDAP error number %d\n",
+ s, ld->ld_errno );
+ }
+
+ if ( ld->ld_matched != NULL ) {
+ fprintf( stderr, "\tmatched: \"%s\"\n",
+ ld->ld_matched );
+ }
+
+ if ( ld->ld_error != NULL ) {
+ fprintf( stderr, "\tadditional info: %s\n",
+ ld->ld_error );