not = verbose = contoper = want_bindpw = debug = 0;
fp = NULL;
authmethod = LDAP_AUTH_SIMPLE;
- version = LDAP_VERSION2;
+ version = -1;
while (( i = getopt( argc, argv, "WnvkKch:P:p:D:w:d:f:" )) != EOF ) {
switch( i ) {
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" );
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 ) {
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" );
infile = NULL;
not = contoper = verbose = remove = want_bindpw = debug = 0;
authmethod = LDAP_AUTH_SIMPLE;
- version = LDAP_VERSION2;
+ version = -1;
myname = (myname = strrchr(argv[0], '/')) == NULL ? argv[0] : ++myname;
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" );
int i, j;
int ldapport = 0;
int debug = 0;
- int scope = LDAP_SCOPE_SUBTREE;
- int sizelimit = LDAP_NO_LIMIT;
- int timelimit = LDAP_NO_LIMIT;
- int version = LDAP_VERSION2;
+ int scope = -1;
+ int sizelimit = -1;
+ int timelimit = -1;
+ int version = -1;
int want_bindpw = 0;
int want_newpw = 0;
LDAP *ld;
}
/* set options */
- ldap_set_option (ld, LDAP_OPT_TIMELIMIT, (void *)&timelimit);
- ldap_set_option (ld, LDAP_OPT_SIZELIMIT, (void *)&sizelimit);
+ if( timelimit != -1 ) {
+ ldap_set_option (ld, LDAP_OPT_TIMELIMIT, (void *)&timelimit);
+ }
+ if( sizelimit != -1 ) {
+ ldap_set_option (ld, LDAP_OPT_SIZELIMIT, (void *)&sizelimit);
+ }
/* this seems prudent */
{
ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
}
- ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
+ if( version != -1 ) {
+ ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
+ }
/* authenticate to server */
if (ldap_bind_s (ld, binddn, bindpw, authmethod) != LDAP_SUCCESS)
LDAP *ld;
infile = NULL;
- deref = verbose = allow_binary = not = vals2tmp =
+ debug = verbose = allow_binary = not = vals2tmp =
attrsonly = ldif = want_bindpw = 0;
- referrals = (int) LDAP_OPT_ON;
- sizelimit = timelimit = debug = 0;
- scope = LDAP_SCOPE_SUBTREE;
+
+ deref = referrals = sizelimit = timelimit =
+ scope = version = -1;
+
authmethod = LDAP_AUTH_SIMPLE;
- version = LDAP_VERSION2;
while (( i = getopt( argc, argv, "WKknuvtRABLD:s:f:h:b:d:P:p:F:a:w:l:z:S:")) != EOF ) {
switch( i ) {
exit( 1 );
}
- if (ldap_set_option( ld, LDAP_OPT_DEREF, (void *) &deref ) == -1 ) {
+ if (deref != -1 &&
+ ldap_set_option( ld, LDAP_OPT_DEREF, (void *) &deref ) == -1 )
+ {
/* set option error */
}
- if (ldap_set_option( ld, LDAP_OPT_TIMELIMIT, (void *) &timelimit ) == -1 ) {
+ if (timelimit != -1 &&
+ ldap_set_option( ld, LDAP_OPT_TIMELIMIT, (void *) &timelimit ) == -1 )
+ {
/* set option error */
}
- if (ldap_set_option( ld, LDAP_OPT_SIZELIMIT, (void *) &sizelimit ) == -1 ) {
+ if (sizelimit != -1 &&
+ ldap_set_option( ld, LDAP_OPT_SIZELIMIT, (void *) &sizelimit ) == -1 )
+ {
/* set option error */
}
- if (ldap_set_option( ld, LDAP_OPT_REFERRALS, (void *) referrals ) == -1 ) {
+ if (referrals != -1 &&
+ ldap_set_option( ld, LDAP_OPT_REFERRALS, (void *) referrals ) == -1 )
+ {
/* set option error */
}
- if (ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) == -1) {
+ if (version != -1 &&
+ ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) == -1)
+ {
/* set option error */
}