add domainScope control support

This commit is contained in:
Kurt Zeilenga 2003-02-09 06:14:06 +00:00
parent 282f6bc32d
commit 89489ae534
2 changed files with 41 additions and 6 deletions

View File

@ -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 );

View File

@ -64,6 +64,9 @@ usage( void )
" -A retrieve attribute names only (no values)\n"
" -b basedn base dn for search\n"
" -E [!]<ctrl>[=<ctrlparam>] search controls (! indicates criticality)\n"
#ifdef LDAP_CONTROL_X_DOMAIN_SCOPE
" [!]domainScope (domain scope)\n"
#endif
" [!]mv=<filter> (matched values filter)\n"
#ifdef LDAP_CONTROL_PAGEDRESULTS
" [!]pr=<size> (paged results)\n"
@ -72,15 +75,15 @@ usage( void )
" [!]subentries[=true|false] (subentries)\n"
#endif
#ifdef LDAP_CLIENT_UPDATE
" [!]lcup= p/<cint>/<cookie>/<slimit> (client update)\n"
" [!]lcup=p/<cint>/<cookie>/<slimit> (LDAP client update)\n"
/*
* " s/<cint>/<cookie> (client update)\n"
* " s/<cint>/<cookie> (LDAP client update)\n"
* " sp/<cint>/<cookie>/<slimit>\n"
* */
#endif
#ifdef LDAP_SYNC
" [!]sync= ro[/<cookie>] (ldap sync - refreshOnly)\n"
" rp[/<cookie>][/<slimit>] (ldap sync - refreshAndPersist)\n"
" [!]sync=ro[/<cookie>] (LDAP Sync refreshOnly)\n"
" rp[/<cookie>][/<slimit>] (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 ) {