#include <stdlib.h>
#include <ac/ctype.h>
+#include <ac/signal.h>
#include <ac/string.h>
#include <ac/unistd.h>
infile = NULL;
not = verbose = valsfromfiles = want_bindpw = debug = 0;
authmethod = LDAP_AUTH_SIMPLE;
- version = LDAP_VERSION2;
+ version = -1;
while (( i = getopt( argc, argv, "WFabckKnrtvh:p:D:w:d:f:" )) != EOF ) {
switch( i ) {
ldif_debug = debug;
}
+#ifdef SIGPIPE
+ (void) SIGNAL( SIGPIPE, SIG_IGN );
+#endif
+
if ( !not ) {
- if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
- perror( "ldap_open" );
+ if (( ld = ldap_init( ldaphost, ldapport )) == NULL ) {
+ perror( "ldap_init" );
exit( 1 );
}
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");
- ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
+ if( version != -1 ) {
+ ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
+ }
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
if ( !use_ldif && ( q = strchr( rbuf, '\n' )) != NULL ) {
for ( p = rbuf; p < q; ++p ) {
- if ( !isdigit( *p )) {
+ if ( !isdigit( (unsigned char) *p )) {
break;
}
}
value = p;
}
- for ( attr = line; *attr != '\0' && isspace( *attr ); ++attr ) {
+ for ( attr = line;
+ *attr != '\0' && isspace( (unsigned char) *attr ); ++attr ) {
; /* skip attribute leading white space */
}
- for ( q = p - 1; q > attr && isspace( *q ); --q ) {
+ for ( q = p - 1; q > attr && isspace( (unsigned char) *q ); --q ) {
*q = '\0'; /* remove attribute trailing white space */
}
if ( value != NULL ) {
- while ( isspace( *value )) {
+ while ( isspace( (unsigned char) *value )) {
++value; /* skip value leading white space */
}
for ( q = value + strlen( value ) - 1; q > value &&
- isspace( *q ); --q ) {
+ isspace( (unsigned char) *q ); --q ) {
*q = '\0'; /* remove value trailing white space */
}
if ( *value == '\0' ) {