From 4ce42af1960708095e15b76e76ad8fa683f90fe7 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 30 Aug 2002 07:05:12 +0000 Subject: [PATCH] Add client-side subentries control support. Make sure client controls are not specified multiple times. NT port updates. --- build/main.dsw | 15 +++++++++++++ clients/tools/ldapcompare.c | 10 +++++++++ clients/tools/ldapdelete.c | 8 +++++++ clients/tools/ldapmodify.c | 8 +++++++ clients/tools/ldapmodrdn.c | 8 +++++++ clients/tools/ldappasswd.c | 4 ++++ clients/tools/ldapsearch.c | 43 +++++++++++++++++++++++++++++++++---- clients/tools/ldapwhoami.c | 8 +++++++ 8 files changed, 100 insertions(+), 4 deletions(-) diff --git a/build/main.dsw b/build/main.dsw index b5d01bfcb8..49380a9415 100644 --- a/build/main.dsw +++ b/build/main.dsw @@ -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 }}} ############################################################################### diff --git a/clients/tools/ldapcompare.c b/clients/tools/ldapcompare.c index 80d049f161..e1ed0f74c7 100644 --- a/clients/tools/ldapcompare.c +++ b/clients/tools/ldapcompare.c @@ -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); diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index f08bdba11f..bc9d057dda 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -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); diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 6ce9d99f9b..11da9b20cf 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -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); diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index 68633b8439..cc36d120c0 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -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); diff --git a/clients/tools/ldappasswd.c b/clients/tools/ldappasswd.c index dda3651ab5..d2ad739ec2 100644 --- a/clients/tools/ldappasswd.c +++ b/clients/tools/ldappasswd.c @@ -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); diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 05ebceb997..5635eec9e6 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -55,7 +55,10 @@ usage( const char *s ) " -A retrieve attribute names only (no values)\n" " -b basedn base dn for search\n" " -E [!][=] search controls (! indicates criticality)\n" -" [!]mv= (matched values filter)\n" +" [!]mv= (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 ); diff --git a/clients/tools/ldapwhoami.c b/clients/tools/ldapwhoami.c index 59713212b6..054ef2caee 100644 --- a/clients/tools/ldapwhoami.c +++ b/clients/tools/ldapwhoami.c @@ -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); -- 2.39.5