Set version to required protocol.
if ( ( authmethod == LDAP_AUTH_KRBV4 ) || ( authmethod ==
LDAP_AUTH_KRBV41 ) ) {
- if( version != LDAP_VERSION2 ) {
+ if( version > LDAP_VERSION2 ) {
fprintf( stderr, "Kerberos requires LDAPv2\n" );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION2;
}
else if ( authmethod == LDAP_AUTH_SASL ) {
- if( version != LDAP_VERSION3 ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
fprintf( stderr, "SASL requires LDAPv3\n" );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION3;
}
if( manageDSAit ) {
- if( version != LDAP_VERSION3 ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
fprintf(stderr, "manage DSA control requires LDAPv3\n");
return EXIT_FAILURE;
}
+ version = LDAP_VERSION3;
+ }
+
+ if( use_tls ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
+ fprintf(stderr, "Start TLS requires LDAPv3\n");
+ return EXIT_FAILURE;
+ }
+ version = LDAP_VERSION3;
}
if ( fp == NULL ) {
if ( ( authmethod == LDAP_AUTH_KRBV4 ) || ( authmethod ==
LDAP_AUTH_KRBV41 ) ) {
- if( version != LDAP_VERSION2 ) {
+ if( version > LDAP_VERSION2 ) {
fprintf( stderr, "Kerberos requires LDAPv2\n" );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION2;
}
else if ( authmethod == LDAP_AUTH_SASL ) {
- if( version != LDAP_VERSION3 ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
fprintf( stderr, "SASL requires LDAPv3\n" );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION3;
}
if( manageDSAit ) {
- if( version != LDAP_VERSION3 ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
fprintf(stderr, "manage DSA control requires LDAPv3\n");
return EXIT_FAILURE;
}
+ version = LDAP_VERSION3;
+ }
+
+ if( use_tls ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
+ fprintf(stderr, "Start TLS requires LDAPv3\n");
+ return EXIT_FAILURE;
+ }
+ version = LDAP_VERSION3;
}
if ( infile != NULL ) {
if ( ( authmethod == LDAP_AUTH_KRBV4 ) || ( authmethod ==
LDAP_AUTH_KRBV41 ) ) {
- if( version != LDAP_VERSION2 ) {
+ if( version > LDAP_VERSION2 ) {
fprintf( stderr, "Kerberos requires LDAPv2\n" );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION2;
}
else if ( authmethod == LDAP_AUTH_SASL ) {
- if( version != LDAP_VERSION3 ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
fprintf( stderr, "SASL requires LDAPv3\n" );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION3;
}
if( manageDSAit ) {
- if( version != LDAP_VERSION3 ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
fprintf(stderr, "manage DSA control requires LDAPv3\n");
return EXIT_FAILURE;
}
+ version = LDAP_VERSION3;
+ }
+
+ if( use_tls ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
+ fprintf(stderr, "Start TLS requires LDAPv3\n");
+ return EXIT_FAILURE;
+ }
+ version = LDAP_VERSION3;
}
if (newSuperior != NULL) {
usage( argv[0] );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION3;
}
havedn = 0;
/* don't chase referrals */
ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
+ /* LDAPv3 only */
version = 3;
rc = ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
/* disconnect from server */
ldap_unbind (ld);
- return ( EXIT_SUCCESS );
+ return EXIT_SUCCESS;
}
if ( ( authmethod == LDAP_AUTH_KRBV4 ) || ( authmethod ==
LDAP_AUTH_KRBV41 ) ) {
- if( version != LDAP_VERSION2 ) {
-
+ if( version > LDAP_VERSION2 ) {
fprintf( stderr, "Kerberos requires LDAPv2\n" );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION2;
}
else if ( authmethod == LDAP_AUTH_SASL ) {
- if( version != LDAP_VERSION3 ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
fprintf( stderr, "SASL requires LDAPv3\n" );
return( EXIT_FAILURE );
}
+ version = LDAP_VERSION3;
}
if( manageDSAit ) {
- if( version != LDAP_VERSION3 ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
fprintf(stderr, "manage DSA control requires LDAPv3\n");
return EXIT_FAILURE;
}
+ version = LDAP_VERSION3;
+ }
+
+ if( use_tls ) {
+ if( version != -1 || version != LDAP_VERSION3 ) {
+ fprintf(stderr, "Start TLS requires LDAPv3\n");
+ return EXIT_FAILURE;
+ }
+ version = LDAP_VERSION3;
}
if ( argc - optind < 1 ) {