]> git.sur5r.net Git - openldap/commitdiff
Add checks to ensure arguments are consistent (v2 vs v3).
authorKurt Zeilenga <kurt@openldap.org>
Sun, 12 Dec 1999 05:05:20 +0000 (05:05 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 12 Dec 1999 05:05:20 +0000 (05:05 +0000)
clients/tools/ldapdelete.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldapsearch.c

index 6351df28c86bd6ba7d34b599de194c88ab8990f6..bfb02bc13d67db18c8e1f5d47ac418583f8768de 100644 (file)
@@ -135,6 +135,22 @@ main( int argc, char **argv )
        }
     }
 
+       if( authmethod != LDAP_AUTH_SIMPLE ) {
+               if( version == LDAP_VERSION3 ) {
+                       fprintf(stderr, "Kerberos requires LDAPv2\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION2;
+       }
+
+       if( manageDSAit ) {
+               if( version == LDAP_VERSION2 ) {
+                       fprintf(stderr, "manage DSA control requires LDAPv3\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION3;
+       }
+
     if ( fp == NULL ) {
        if ( optind >= argc ) {
            fp = stdin;
@@ -168,15 +184,15 @@ main( int argc, char **argv )
        /* don't chase referrals */
        ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
 
-       if (want_bindpw)
-               passwd = getpass("Enter LDAP Password: ");
-
        if (version != -1 &&
                ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != LDAP_OPT_SUCCESS)
        {
                fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n", version );
        }
 
+       if (want_bindpw)
+               passwd = getpass("Enter LDAP Password: ");
+
     if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
        ldap_perror( ld, "ldap_bind" );
        return( EXIT_FAILURE );
@@ -268,7 +284,7 @@ static int deletechildren( LDAP *ld,
     /*
      * Do a one level search at dn for children.  For each, delete its children.
      */
-    if ( ldap_search_s( ld, dn, LDAP_SCOPE_ONELEVEL, "objectclass=*", NULL, 0, &res ) == -1 )
+    if ( ldap_search_s( ld, dn, LDAP_SCOPE_ONELEVEL, "(objectclass=*)", NULL, 0, &res ) == -1 )
     {
         ldap_perror( ld, "ldap_search" );
                ldap_get_option( ld, LDAP_OPT_ERROR_NUMBER, &rc );
index 043d3bbc3dafd888a528f3932e88298c0c25daae..55c3b6f0b9d5929e67032d5ac95de57d14fed395 100644 (file)
@@ -218,6 +218,22 @@ main( int argc, char **argv )
     if ( argc != optind )
        usage( prog );
 
+       if( authmethod != LDAP_AUTH_SIMPLE ) {
+               if( version == LDAP_VERSION3 ) {
+                       fprintf(stderr, "Kerberos requires LDAPv2\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION2;
+       }
+
+       if( manageDSAit ) {
+               if( version == LDAP_VERSION2 ) {
+                       fprintf(stderr, "manage DSA control requires LDAPv3\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION3;
+       }
+
     if ( infile != NULL ) {
        if (( fp = fopen( infile, "r" )) == NULL ) {
            perror( infile );
@@ -255,15 +271,15 @@ main( int argc, char **argv )
        /* don't chase referrals */
        ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
 
-       if (want_bindpw)
-               passwd = getpass("Enter LDAP Password: ");
-
        if (version != -1 &&
                ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != LDAP_OPT_SUCCESS)
        {
                fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION to %d\n", version );
        }
 
+       if (want_bindpw)
+               passwd = getpass("Enter LDAP Password: ");
+
        if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
            ldap_perror( ld, "ldap_bind" );
            return( EXIT_FAILURE );
index 0070011adf1f58840d86185ebed2d527c5912778..efaa002d4320e2dc0c14629c45455d3395ea273e 100644 (file)
@@ -148,6 +148,22 @@ main(int argc, char **argv)
        }
     }
 
+       if( authmethod != LDAP_AUTH_SIMPLE ) {
+               if( version == LDAP_VERSION3 ) {
+                       fprintf(stderr, "Kerberos requires LDAPv2\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION2;
+       }
+
+       if( manageDSAit ) {
+               if( version == LDAP_VERSION2 ) {
+                       fprintf(stderr, "manage DSA control requires LDAPv3\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION3;
+       }
+
     if (newSuperior != NULL) {
                if (version == LDAP_VERSION2) {
                        fprintf( stderr,
@@ -214,15 +230,15 @@ main(int argc, char **argv)
        ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
 
 
-       if (want_bindpw)
-               passwd = getpass("Enter LDAP Password: ");
-
        if (version != -1 &&
                ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != LDAP_OPT_SUCCESS)
        {
                fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n", version );
        }
 
+       if (want_bindpw)
+               passwd = getpass("Enter LDAP Password: ");
+
     if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
        ldap_perror( ld, "ldap_bind" );
        return( EXIT_FAILURE );
index 6a66a80ad16f96c7e421d2075dcdb92317580252..a56e667fcf8b73c0c7b2c86869e3fd4157d4becd 100644 (file)
@@ -273,6 +273,22 @@ main( int argc, char **argv )
        }
        }
 
+       if( authmethod != LDAP_AUTH_SIMPLE ) {
+               if( version == LDAP_VERSION3 ) {
+                       fprintf(stderr, "Kerberos requires LDAPv2\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION2;
+       }
+
+       if( manageDSAit ) {
+               if( version == LDAP_VERSION2 ) {
+                       fprintf(stderr, "manage DSA control requires LDAPv3\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION3;
+       }
+
        if ( argc - optind < 1 ) {
                usage( argv[ 0 ] );
        }