]> git.sur5r.net Git - openldap/commitdiff
Add client-side subentries control support.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 30 Aug 2002 07:05:12 +0000 (07:05 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 30 Aug 2002 07:05:12 +0000 (07:05 +0000)
Make sure client controls are not specified multiple times.
NT port updates.

build/main.dsw
clients/tools/ldapcompare.c
clients/tools/ldapdelete.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldappasswd.c
clients/tools/ldapsearch.c
clients/tools/ldapwhoami.c

index b5d01bfcb82859ffc0720adcaba8c75d9d9faf97..49380a9415dc1a13232920466a7c3ff03f329b9e 100644 (file)
@@ -155,6 +155,9 @@ Package=<4>
     Begin Project Dependency
     Project_Dep_Name ldapwhoami
     End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name ldapcompare
+    End Project Dependency
 }}}
 
 ###############################################################################
@@ -239,6 +242,18 @@ Package=<5>
 
 Package=<4>
 {{{
+    Begin Project Dependency
+    Project_Dep_Name liblber
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldap
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name liblutil
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldif
+    End Project Dependency
 }}}
 
 ###############################################################################
index 80d049f16190f05e8fe2bd7732655cab6b901d66..e1ed0f74c7e33583ff1251ef03b189c12d3ad01f 100644 (file)
@@ -130,6 +130,7 @@ main( int argc, char **argv )
                "Cd:D:e:h:H:IkKMnO:p:P:qQR:U:vw:WxX:y:Y:zZ")) != EOF )
        {
                switch( i ) {
+#if 0
        case 'E': /* compare controls */
                if( version == LDAP_VERSION2 ) {
                        fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
@@ -155,6 +156,7 @@ main( int argc, char **argv )
                fprintf( stderr, "Invalid compare control name: %s\n", control );
                usage(prog);
                return EXIT_FAILURE;
+#endif
 
                /* Common Options */
                case 'C':
@@ -195,6 +197,10 @@ main( int argc, char **argv )
                }
 
                if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
+                       if( manageDSAit ) {
+                               fprintf( stderr, "manageDSAit control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "manageDSAit: no control value expected" );
                                usage(prog);
@@ -206,6 +212,10 @@ main( int argc, char **argv )
                        break;
                        
                } else if ( strcasecmp( control, "noop" ) == 0 ) {
+                       if( noop ) {
+                               fprintf( stderr, "noop control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "noop: no control value expected" );
                                usage(prog);
index f08bdba11faca5f167bdf55debd9e8e24f12260e..bc9d057dda9af71130307bbf8f2eb6b4a79d3aeb 100644 (file)
@@ -196,6 +196,10 @@ main( int argc, char **argv )
                }
 
                if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
+                       if( manageDSAit ) {
+                               fprintf( stderr, "manageDSAit control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "manageDSAit: no control value expected" );
                                usage(prog);
@@ -207,6 +211,10 @@ main( int argc, char **argv )
                        break;
                        
                } else if ( strcasecmp( control, "noop" ) == 0 ) {
+                       if( noop ) {
+                               fprintf( stderr, "noop control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "noop: no control value expected" );
                                usage(prog);
index 6ce9d99f9b69ec6a860c56a5e21154a37f253d2d..11da9b20cf1f299a7612e8e9af8a025e161e5dd7 100644 (file)
@@ -253,6 +253,10 @@ main( int argc, char **argv )
                }
 
                if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
+                       if( manageDSAit ) {
+                               fprintf( stderr, "manageDSAit control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "manageDSAit: no control value expected" );
                                usage(prog);
@@ -264,6 +268,10 @@ main( int argc, char **argv )
                        break;
                        
                } else if ( strcasecmp( control, "noop" ) == 0 ) {
+                       if( noop ) {
+                               fprintf( stderr, "noop control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "noop: no control value expected" );
                                usage(prog);
index 68633b8439305a8e20ee012f5dc7e48b86f51ebc..cc36d120c0fae59a838f0c86405f9ba2b5da32c8 100644 (file)
@@ -216,6 +216,10 @@ main(int argc, char **argv)
                }
 
                if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
+                       if( manageDSAit ) {
+                               fprintf( stderr, "manageDSAit control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "manageDSAit: no control value expected" );
                                usage(prog);
@@ -227,6 +231,10 @@ main(int argc, char **argv)
                        break;
                        
                } else if ( strcasecmp( control, "noop" ) == 0 ) {
+                       if( noop ) {
+                               fprintf( stderr, "noop control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "noop: no control value expected" );
                                usage(prog);
index dda3651ab5685f04bac10e50354715f76d783852..d2ad739ec29ced6830f4b7bc23ada718e891dab2 100644 (file)
@@ -214,6 +214,10 @@ main( int argc, char *argv[] )
                }
 
                if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
+                       if( manageDSAit ) {
+                               fprintf( stderr, "manageDSAit control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "manageDSAit: no control value expected" );
                                usage(prog);
index 05ebceb997c6c802c8820bca4a075a760cf27a7b..5635eec9e6bafc1694fff65bf6ab70a9626cbea7 100644 (file)
@@ -55,7 +55,10 @@ usage( const char *s )
 "  -A         retrieve attribute names only (no values)\n"
 "  -b basedn  base dn for search\n"
 "  -E [!]<ctrl>[=<ctrlparam>] search controls (! indicates criticality)\n"
-"             [!]mv=<filter>   (matched values filter)\n"
+"             [!]mv=<filter>              (matched values filter)\n"
+#ifdef LDAP_CONTROL_SUBENTRIES
+"             [!]subentries[=true|false]  (subentries)\n"
+#endif
 "  -F prefix  URL prefix for files (default: %s)\n"
 "  -l limit   time limit (in seconds) for search\n"
 "  -L         print responses in LDIFv1 format\n"
@@ -190,7 +193,7 @@ main( int argc, char **argv )
        int                     referrals, timelimit, sizelimit, debug;
        int             authmethod, version, want_bindpw;
        LDAP            *ld = NULL;
-       int             valuesReturnFilter;
+       int             subentries, valuesReturnFilter;
        BerElement      *ber = NULL;
        struct berval   *bvalp = NULL;
        char    *vrFilter  = NULL, *control = NULL, *cvalue;
@@ -198,7 +201,8 @@ main( int argc, char **argv )
 
 
        infile = NULL;
-       debug = verbose = not = vals2tmp = referrals = valuesReturnFilter =
+       debug = verbose = not = vals2tmp = referrals =
+               subentries = valuesReturnFilter =
                attrsonly = manageDSAit = noop = ldif = want_bindpw = 0;
 
        prog = lutil_progname( "ldapsearch", argc, argv );
@@ -282,7 +286,7 @@ main( int argc, char **argv )
 
                if ( strcasecmp( control, "mv" ) == 0 ) {
                        /* ValuesReturnFilter control */
-                       if (valuesReturnFilter!=0) {
+                       if( valuesReturnFilter ) {
                                fprintf( stderr, "ValuesReturnFilter previously specified");
                                return EXIT_FAILURE;
                        }
@@ -298,6 +302,24 @@ main( int argc, char **argv )
                        version = LDAP_VERSION3;
                        break;
 
+#ifdef LDAP_CONTROL_SUBENTRIES
+               } else if ( strcasecmp( control, "subentries" ) == 0 ) {
+                       if( subentries ) {
+                               fprintf( stderr, "subentries control previously specified");
+                               return EXIT_FAILURE;
+                       }
+                       if( cvalue == NULL || strcasecmp( cvalue, "true") == 0 ) {
+                               subentries = 2;
+                       } else if ( strcasecmp( cvalue, "false") == 0 ) {
+                               subentries = 1;
+                       } else {
+                               fprintf( stderr,
+                                       "subentries control value \"%s\" invalid\n");
+                               return EXIT_FAILURE;
+                       }
+                       if( crit ) subentries *= -1;
+#endif
+
                } else {
                        fprintf( stderr, "Invalid control name: %s\n", control );
                        usage(prog);
@@ -392,6 +414,10 @@ main( int argc, char **argv )
                }
 
                if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
+                       if( manageDSAit ) {
+                               fprintf( stderr, "manageDSAit control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "manageDSAit: no control value expected" );
                                usage(prog);
@@ -403,6 +429,10 @@ main( int argc, char **argv )
                        break;
                        
                } else if ( strcasecmp( control, "noop" ) == 0 ) {
+                       if( noop ) {
+                               fprintf( stderr, "noop control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "noop: no control value expected" );
                                usage(prog);
@@ -1051,6 +1081,11 @@ main( int argc, char **argv )
                        printf("\n# with noop %scontrol",
                                noop > 1 ? "critical " : "" );
                }
+               if ( subentries ) {
+                       printf("\n# with subentries %scontrol: %s",
+                               subentries < 0 ? "critical " : "",
+                               abs(subentries) == 1 ? "false" : "true" );
+               }
                if ( valuesReturnFilter ) {
                        printf("\n# with valuesReturnFilter %scontrol: %s",
                                valuesReturnFilter > 1 ? "critical " : "", vrFilter );
index 59713212b63e16fec6baba703853a3c9a1ddf746..054ef2caeec2adfae68867ca7689d7b3df7f7c01 100644 (file)
@@ -174,6 +174,10 @@ main( int argc, char *argv[] )
                }
 
                if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
+                       if( manageDSAit ) {
+                               fprintf( stderr, "manageDSAit control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "manageDSAit: no control value expected" );
                                usage(prog);
@@ -185,6 +189,10 @@ main( int argc, char *argv[] )
                        break;
                        
                } else if ( strcasecmp( control, "noop" ) == 0 ) {
+                       if( noop ) {
+                               fprintf( stderr, "noop control previously specified");
+                               return EXIT_FAILURE;
+                       }
                        if( cvalue != NULL ) {
                                fprintf( stderr, "noop: no control value expected" );
                                usage(prog);