From 89489ae5340a8f70b78bd57c849d10999c2ca90c Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sun, 9 Feb 2003 06:14:06 +0000 Subject: [PATCH] add domainScope control support --- clients/tools/common.c | 2 +- clients/tools/ldapsearch.c | 45 +++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/clients/tools/common.c b/clients/tools/common.c index b477850942..3b4983336c 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -653,7 +653,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count ) int i = 0, j, crit = 0, err; LDAPControl c[3], **ctrls; - ctrls = (LDAPControl **)malloc( sizeof(c) + (count + 1)*sizeof(LDAPControl *) ); + ctrls = (LDAPControl**) malloc(sizeof(c) + (count+1)*sizeof(LDAPControl*)); if ( ctrls == NULL ) { fprintf( stderr, "No memory\n" ); exit( EXIT_FAILURE ); diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index e65ca0ca36..12266635d1 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -64,6 +64,9 @@ usage( void ) " -A retrieve attribute names only (no values)\n" " -b basedn base dn for search\n" " -E [!][=] search controls (! indicates criticality)\n" +#ifdef LDAP_CONTROL_X_DOMAIN_SCOPE +" [!]domainScope (domain scope)\n" +#endif " [!]mv= (matched values filter)\n" #ifdef LDAP_CONTROL_PAGEDRESULTS " [!]pr= (paged results)\n" @@ -72,15 +75,15 @@ usage( void ) " [!]subentries[=true|false] (subentries)\n" #endif #ifdef LDAP_CLIENT_UPDATE -" [!]lcup= p/// (client update)\n" +" [!]lcup=p/// (LDAP client update)\n" /* - * " s// (client update)\n" + * " s// (LDAP client update)\n" * " sp///\n" * */ #endif #ifdef LDAP_SYNC -" [!]sync= ro[/] (ldap sync - refreshOnly)\n" -" rp[/][/] (ldap sync - refreshAndPersist)\n" +" [!]sync=ro[/] (LDAP Sync refreshOnly)\n" +" rp[/][/] (LDAP Sync refreshAndPersist)\n" #endif " -F prefix URL prefix for files (default: %s)\n" " -l limit time limit (in seconds) for search\n" @@ -153,6 +156,10 @@ static int includeufn, vals2tmp = 0, ldif = 0; static int subentries = 0, valuesReturnFilter = 0; static char *vrFilter = NULL; +#ifdef LDAP_CONTROL_X_DOMAIN_SCOPE +static int domainScope = 0; +#endif + #if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC) static int lcup = 0; static int ldapsync = 0; @@ -289,6 +296,21 @@ handle_private_option( int i ) pagedResults = 1 + crit; #endif +#ifdef LDAP_CONTROL_X_DOMAIN_SCOPE + } else if ( strcasecmp( control, "domainScope" ) == 0 ) { + if( domainScope ) { + fprintf( stderr, + "domainScope control previously specified\n"); + exit( EXIT_FAILURE ); + } + if( cvalue != NULL ) { + fprintf( stderr, + "domainScope: no control value expected\n" ); + usage(); + } + + domainScope = 1 + crit; +#endif #ifdef LDAP_CONTROL_SUBENTRIES } else if ( strcasecmp( control, "subentries" ) == 0 ) { if( subentries ) { @@ -609,6 +631,9 @@ main( int argc, char **argv ) getNextPage: if ( manageDSAit || noop || subentries || valuesReturnFilter +#ifdef LDAP_CONTROL_X_DOMAIN_SCOPE + || domainScope +#endif #ifdef LDAP_CONTROL_PAGEDRESULTS || pageSize #endif @@ -621,7 +646,17 @@ getNextPage: ) { int err; int i=0; - LDAPControl c[3]; + LDAPControl c[6]; + +#ifdef LDAP_CONTROL_X_DOMAIN_SCOPE + if ( domainScope ) { + c[i].ldctl_oid = LDAP_CONTROL_X_DOMAIN_SCOPE; + c[i].ldctl_value.bv_val = NULL; + c[i].ldctl_value.bv_len = 0; + c[i].ldctl_iscritical = domainScope > 1; + i++; + } +#endif #ifdef LDAP_CONTROL_SUBENTRIES if ( subentries ) { -- 2.39.5