Skip to content
Snippets Groups Projects
Commit 8d1523c5 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Make ldap_set_option options optional.

parent cfa450d0
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ main( int argc, char **argv )
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 ) {
......@@ -131,7 +131,9 @@ main( int argc, char **argv )
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" );
......
......@@ -81,7 +81,7 @@ main( int argc, char **argv )
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 ) {
......@@ -193,7 +193,9 @@ main( int argc, char **argv )
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" );
......
......@@ -40,7 +40,7 @@ main(int argc, char **argv)
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;
......@@ -155,7 +155,9 @@ main(int argc, char **argv)
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" );
......
......@@ -360,10 +360,10 @@ main (int argc, char *argv[])
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;
......@@ -559,8 +559,12 @@ main (int argc, char *argv[])
}
/* 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 */
{
......@@ -568,7 +572,9 @@ main (int argc, char *argv[])
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)
......
......@@ -93,13 +93,13 @@ main( int argc, char **argv )
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 ) {
......@@ -268,20 +268,30 @@ main( int argc, char **argv )
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 */
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment