mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-18 18:18:06 -05:00
control updates
This commit is contained in:
parent
5138e8f954
commit
63f9bcdcf1
8 changed files with 908 additions and 97 deletions
|
|
@ -47,6 +47,9 @@ usage( const char *s )
|
|||
"Common options:\n"
|
||||
" -d level set LDAP debugging level to `level'\n"
|
||||
" -D binddn bind DN\n"
|
||||
" -e [!]<ctrl>[=<ctrlparam>] general controls (! indicates criticality)\n"
|
||||
" [!]manageDSAit (alternate form, see -M)\n"
|
||||
" [!]noop\n"
|
||||
" -h host LDAP server\n"
|
||||
" -H URI LDAP Uniform Resource Indentifier(s)\n"
|
||||
" -I use SASL Interactive mode\n"
|
||||
|
|
@ -105,14 +108,15 @@ main( int argc, char **argv )
|
|||
{
|
||||
char *compdn = NULL, *attrs = NULL;
|
||||
char *sep;
|
||||
int rc, i, manageDSAit, quiet;
|
||||
int rc, i, crit, manageDSAit, noop, quiet;
|
||||
int referrals, debug;
|
||||
int authmethod, version, want_bindpw;
|
||||
LDAP *ld = NULL;
|
||||
struct berval bvalue = { 0, NULL };
|
||||
char *pw_file = NULL;
|
||||
char *control, *cvalue;
|
||||
|
||||
debug = verbose = not = referrals =
|
||||
debug = verbose = not = referrals = noop =
|
||||
manageDSAit = want_bindpw = quiet = 0;
|
||||
|
||||
version = -1;
|
||||
|
|
@ -122,9 +126,34 @@ main( int argc, char **argv )
|
|||
prog = lutil_progname( "ldapcompare", argc, argv );
|
||||
|
||||
while (( i = getopt( argc, argv,
|
||||
"Cd:D:h:H:IkKMnO:p:P:qQR:U:vw:WxX:y:Y:zZ")) != EOF )
|
||||
"Cd:D:e:h:H:IkKMnO:p:P:qQR:U:vw:WxX:y:Y:zZ")) != EOF )
|
||||
{
|
||||
switch( i ) {
|
||||
case 'E': /* compare controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -E !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
fprintf( stderr, "Invalid compare control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
|
||||
/* Common Options */
|
||||
case 'C':
|
||||
|
|
@ -140,6 +169,57 @@ main( int argc, char **argv )
|
|||
}
|
||||
binddn = strdup( optarg );
|
||||
break;
|
||||
|
||||
case 'e': /* general controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -e incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -e !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
|
||||
if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "manageDSAit: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
manageDSAit = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else if ( strcasecmp( control, "noop" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "noop: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
noop = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else {
|
||||
fprintf( stderr, "Invalid general control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
case 'h': /* ldap host */
|
||||
if( ldapuri != NULL ) {
|
||||
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
|
||||
|
|
@ -646,24 +726,37 @@ main( int argc, char **argv )
|
|||
}
|
||||
}
|
||||
|
||||
if ( manageDSAit ) {
|
||||
int err;
|
||||
LDAPControl c;
|
||||
LDAPControl *ctrls[2];
|
||||
ctrls[0] = &c;
|
||||
ctrls[1] = NULL;
|
||||
if ( manageDSAit || noop ) {
|
||||
int err, i = 0;
|
||||
LDAPControl c1, c2;
|
||||
LDAPControl *ctrls[3];
|
||||
|
||||
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c.ldctl_value.bv_val = NULL;
|
||||
c.ldctl_value.bv_len = 0;
|
||||
c.ldctl_iscritical = manageDSAit > 1;
|
||||
if ( manageDSAit ) {
|
||||
ctrls[i++] = &c1;
|
||||
ctrls[i] = NULL;
|
||||
c1.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c1.ldctl_value.bv_val = NULL;
|
||||
c1.ldctl_value.bv_len = 0;
|
||||
c1.ldctl_iscritical = manageDSAit > 1;
|
||||
}
|
||||
|
||||
if ( noop ) {
|
||||
ctrls[i++] = &c2;
|
||||
ctrls[i] = NULL;
|
||||
|
||||
c2.ldctl_oid = LDAP_CONTROL_NOOP;
|
||||
c2.ldctl_value.bv_val = NULL;
|
||||
c2.ldctl_value.bv_len = 0;
|
||||
c2.ldctl_iscritical = noop > 1;
|
||||
}
|
||||
|
||||
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
|
||||
|
||||
if( err != LDAP_OPT_SUCCESS ) {
|
||||
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
|
||||
c.ldctl_iscritical ? "critical " : "" );
|
||||
if( c.ldctl_iscritical ) {
|
||||
fprintf( stderr, "Could not set %scontrols\n",
|
||||
(c1.ldctl_iscritical || c2.ldctl_iscritical)
|
||||
? "critical " : "" );
|
||||
if ( c1.ldctl_iscritical && c2.ldctl_iscritical ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ usage( const char *s )
|
|||
"Common options:\n"
|
||||
" -d level set LDAP debugging level to `level'\n"
|
||||
" -D binddn bind DN\n"
|
||||
" -e [!]<ctrl>[=<ctrlparam>] general controls (! indicates criticality)\n"
|
||||
" [!]manageDSAit (alternate form, see -M)\n"
|
||||
" [!]noop\n"
|
||||
" -f file read operations from `file'\n"
|
||||
" -h host LDAP server\n"
|
||||
" -H URI LDAP Uniform Resource Indentifier(s)\n"
|
||||
|
|
@ -95,10 +98,12 @@ main( int argc, char **argv )
|
|||
{
|
||||
char buf[ 4096 ];
|
||||
FILE *fp;
|
||||
int i, rc, authmethod, referrals, want_bindpw, version, debug, manageDSAit;
|
||||
int i, rc, authmethod, referrals, want_bindpw, version, debug, manageDSAit, noop, crit;
|
||||
char *pw_file;
|
||||
char *control, *cvalue;
|
||||
|
||||
not = verbose = contoper = want_bindpw = debug = manageDSAit = referrals = 0;
|
||||
not = verbose = contoper = want_bindpw = debug
|
||||
= manageDSAit = noop = referrals = 0;
|
||||
fp = NULL;
|
||||
authmethod = -1;
|
||||
version = -1;
|
||||
|
|
@ -107,13 +112,38 @@ main( int argc, char **argv )
|
|||
prog = lutil_progname( "ldapdelete", argc, argv );
|
||||
|
||||
while (( i = getopt( argc, argv, "cf:r"
|
||||
"Cd:D:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z" )) != EOF )
|
||||
"Cd:D:e:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z" )) != EOF )
|
||||
{
|
||||
switch( i ) {
|
||||
/* Delete Specific Options */
|
||||
case 'c': /* continuous operation mode */
|
||||
++contoper;
|
||||
break;
|
||||
case 'E': /* delete controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -E !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
fprintf( stderr, "Invalid delete control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
case 'f': /* read DNs from a file */
|
||||
if( fp != NULL ) {
|
||||
fprintf( stderr, "%s: -f previously specified\n", prog );
|
||||
|
|
@ -142,6 +172,56 @@ main( int argc, char **argv )
|
|||
}
|
||||
binddn = strdup( optarg );
|
||||
break;
|
||||
case 'e': /* general controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -e incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -e !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
|
||||
if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "manageDSAit: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
manageDSAit = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else if ( strcasecmp( control, "noop" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "noop: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
noop = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else {
|
||||
fprintf( stderr, "Invalid general control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
case 'h': /* ldap host */
|
||||
if( ldapuri != NULL ) {
|
||||
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
|
||||
|
|
@ -614,25 +694,38 @@ main( int argc, char **argv )
|
|||
}
|
||||
}
|
||||
|
||||
if ( manageDSAit ) {
|
||||
int err;
|
||||
LDAPControl c;
|
||||
LDAPControl *ctrls[2];
|
||||
ctrls[0] = &c;
|
||||
ctrls[1] = NULL;
|
||||
if ( manageDSAit || noop ) {
|
||||
int err, i = 0;
|
||||
LDAPControl c1, c2;
|
||||
LDAPControl *ctrls[3];
|
||||
|
||||
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c.ldctl_value.bv_val = NULL;
|
||||
c.ldctl_value.bv_len = 0;
|
||||
c.ldctl_iscritical = manageDSAit > 1;
|
||||
if ( manageDSAit ) {
|
||||
ctrls[i++] = &c1;
|
||||
ctrls[i] = NULL;
|
||||
c1.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c1.ldctl_value.bv_val = NULL;
|
||||
c1.ldctl_value.bv_len = 0;
|
||||
c1.ldctl_iscritical = manageDSAit > 1;
|
||||
}
|
||||
|
||||
if ( noop ) {
|
||||
ctrls[i++] = &c2;
|
||||
ctrls[i] = NULL;
|
||||
|
||||
c2.ldctl_oid = LDAP_CONTROL_NOOP;
|
||||
c2.ldctl_value.bv_val = NULL;
|
||||
c2.ldctl_value.bv_len = 0;
|
||||
c2.ldctl_iscritical = noop > 1;
|
||||
}
|
||||
|
||||
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
|
||||
|
||||
if( err != LDAP_OPT_SUCCESS ) {
|
||||
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
|
||||
c.ldctl_iscritical ? "critical " : "" );
|
||||
if( c.ldctl_iscritical ) {
|
||||
exit( EXIT_FAILURE );
|
||||
fprintf( stderr, "Could not set %scontrols\n",
|
||||
(c1.ldctl_iscritical || c2.ldctl_iscritical)
|
||||
? "critical " : "" );
|
||||
if ( c1.ldctl_iscritical && c2.ldctl_iscritical ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,13 +105,16 @@ usage( const char *prog )
|
|||
"Add or modify options:\n"
|
||||
" -a add values (default%s)\n"
|
||||
" -c continuous operation mode (do not stop on errors)\n"
|
||||
" -f file read operations from `file'\n"
|
||||
" -F force all changes records to be used\n"
|
||||
" -S file write skipped modifications to `file'\n"
|
||||
|
||||
"Common options:\n"
|
||||
" -d level set LDAP debugging level to `level'\n"
|
||||
" -D binddn bind DN\n"
|
||||
" -e [!]<ctrl>[=<ctrlparam>] general controls (! indicates criticality)\n"
|
||||
" [!]manageDSAit (alternate form, see -M)\n"
|
||||
" [!]noop\n"
|
||||
" -f file read operations from `file'\n"
|
||||
" -h host LDAP server\n"
|
||||
" -H URI LDAP Uniform Resource Indentifier(s)\n"
|
||||
" -I use SASL Interactive mode\n"
|
||||
|
|
@ -145,9 +148,11 @@ main( int argc, char **argv )
|
|||
char *infile, *rejfile, *rbuf, *start, *rejbuf = NULL;
|
||||
FILE *fp, *rejfp;
|
||||
char *matched_msg = NULL, *error_msg = NULL;
|
||||
int rc, i, authmethod, version, want_bindpw, debug, manageDSAit, referrals;
|
||||
int rc, i, authmethod, version, want_bindpw, debug, manageDSAit, noop, referrals;
|
||||
int count, len;
|
||||
char *pw_file = NULL;
|
||||
char *control, *cvalue;
|
||||
int crit;
|
||||
|
||||
prog = lutil_progname( "ldapmodify", argc, argv );
|
||||
|
||||
|
|
@ -159,12 +164,12 @@ main( int argc, char **argv )
|
|||
|
||||
infile = NULL;
|
||||
rejfile = NULL;
|
||||
not = verbose = want_bindpw = debug = manageDSAit = referrals = 0;
|
||||
not = verbose = want_bindpw = debug = manageDSAit = noop = referrals = 0;
|
||||
authmethod = -1;
|
||||
version = -1;
|
||||
|
||||
while (( i = getopt( argc, argv, "acrf:F"
|
||||
"Cd:D:h:H:IkKMnO:p:P:QR:S:U:vw:WxX:y:Y:Z" )) != EOF )
|
||||
while (( i = getopt( argc, argv, "acrf:E:F"
|
||||
"Cd:D:e:h:H:IkKMnO:p:P:QR:S:U:vw:WxX:y:Y:Z" )) != EOF )
|
||||
{
|
||||
switch( i ) {
|
||||
/* Modify Options */
|
||||
|
|
@ -174,6 +179,31 @@ main( int argc, char **argv )
|
|||
case 'c': /* continuous operation */
|
||||
contoper = 1;
|
||||
break;
|
||||
case 'E': /* modify controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -E !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
fprintf( stderr, "Invalid modify control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
case 'f': /* read from file */
|
||||
if( infile != NULL ) {
|
||||
fprintf( stderr, "%s: -f previously specified\n", prog );
|
||||
|
|
@ -199,6 +229,56 @@ main( int argc, char **argv )
|
|||
}
|
||||
binddn = strdup( optarg );
|
||||
break;
|
||||
case 'e': /* general controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -e incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -e !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
|
||||
if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "manageDSAit: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
manageDSAit = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else if ( strcasecmp( control, "noop" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "noop: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
noop = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else {
|
||||
fprintf( stderr, "Invalid general control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
case 'h': /* ldap host */
|
||||
if( ldapuri != NULL ) {
|
||||
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
|
||||
|
|
@ -701,25 +781,38 @@ main( int argc, char **argv )
|
|||
|
||||
rc = 0;
|
||||
|
||||
if ( manageDSAit ) {
|
||||
int err;
|
||||
LDAPControl c;
|
||||
LDAPControl *ctrls[2];
|
||||
ctrls[0] = &c;
|
||||
ctrls[1] = NULL;
|
||||
if ( manageDSAit || noop ) {
|
||||
int err, i = 0;
|
||||
LDAPControl c1, c2;
|
||||
LDAPControl *ctrls[3];
|
||||
|
||||
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c.ldctl_value.bv_val = NULL;
|
||||
c.ldctl_value.bv_len = 0;
|
||||
c.ldctl_iscritical = manageDSAit > 1;
|
||||
if ( manageDSAit ) {
|
||||
ctrls[i++] = &c1;
|
||||
ctrls[i] = NULL;
|
||||
c1.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c1.ldctl_value.bv_val = NULL;
|
||||
c1.ldctl_value.bv_len = 0;
|
||||
c1.ldctl_iscritical = manageDSAit > 1;
|
||||
}
|
||||
|
||||
if ( noop ) {
|
||||
ctrls[i++] = &c2;
|
||||
ctrls[i] = NULL;
|
||||
|
||||
c2.ldctl_oid = LDAP_CONTROL_NOOP;
|
||||
c2.ldctl_value.bv_val = NULL;
|
||||
c2.ldctl_value.bv_len = 0;
|
||||
c2.ldctl_iscritical = noop > 1;
|
||||
}
|
||||
|
||||
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
|
||||
|
||||
if( err != LDAP_OPT_SUCCESS ) {
|
||||
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
|
||||
c.ldctl_iscritical ? "critical " : "" );
|
||||
if( c.ldctl_iscritical ) {
|
||||
exit( EXIT_FAILURE );
|
||||
fprintf( stderr, "Could not set %scontrols\n",
|
||||
(c1.ldctl_iscritical || c2.ldctl_iscritical)
|
||||
? "critical " : "" );
|
||||
if ( c1.ldctl_iscritical && c2.ldctl_iscritical ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ usage( const char *s )
|
|||
"Common options:\n"
|
||||
" -d level set LDAP debugging level to `level'\n"
|
||||
" -D binddn bind DN\n"
|
||||
" -e [!]<ctrl>[=<ctrlparam>] general controls (! indicates criticality)\n"
|
||||
" [!]manageDSAit (alternate form, see -M)\n"
|
||||
" [!]noop\n"
|
||||
" -f file read operations from `file'\n"
|
||||
" -h host LDAP server\n"
|
||||
" -H URI LDAP Uniform Resource Indentifier(s)\n"
|
||||
|
|
@ -108,27 +111,53 @@ main(int argc, char **argv)
|
|||
{
|
||||
char *infile, *entrydn = NULL, *rdn = NULL, buf[ 4096 ];
|
||||
FILE *fp;
|
||||
int rc, i, remove, havedn, authmethod, version, want_bindpw, debug, manageDSAit;
|
||||
int rc, i, remove, havedn, authmethod, version, want_bindpw, debug, manageDSAit, noop, crit;
|
||||
int referrals;
|
||||
char *newSuperior=NULL;
|
||||
char *pw_file = NULL;
|
||||
char *control, *cvalue;
|
||||
|
||||
infile = NULL;
|
||||
not = contoper = verbose = remove = want_bindpw =
|
||||
debug = manageDSAit = referrals = 0;
|
||||
debug = manageDSAit = noop = referrals = 0;
|
||||
authmethod = -1;
|
||||
version = -1;
|
||||
|
||||
prog = lutil_progname( "ldapmodrdn", argc, argv );
|
||||
|
||||
while (( i = getopt( argc, argv, "cf:rs:"
|
||||
"Cd:D:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z" )) != EOF )
|
||||
"Cd:D:e:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z" )) != EOF )
|
||||
{
|
||||
switch( i ) {
|
||||
/* Modrdn Options */
|
||||
case 'c':
|
||||
contoper++;
|
||||
break;
|
||||
case 'E': /* modrdn controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -E !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
fprintf( stderr, "Invalid modrdn control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
case 'f': /* read from file */
|
||||
if( infile != NULL ) {
|
||||
fprintf( stderr, "%s: -f previously specified\n", prog );
|
||||
|
|
@ -163,6 +192,56 @@ main(int argc, char **argv)
|
|||
}
|
||||
binddn = strdup( optarg );
|
||||
break;
|
||||
case 'e': /* general controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -e incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -e !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
|
||||
if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "manageDSAit: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
manageDSAit = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else if ( strcasecmp( control, "noop" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "noop: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
noop = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else {
|
||||
fprintf( stderr, "Invalid general control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
case 'h': /* ldap host */
|
||||
if( ldapuri != NULL ) {
|
||||
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
|
||||
|
|
@ -650,25 +729,38 @@ main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if ( manageDSAit ) {
|
||||
int err;
|
||||
LDAPControl c;
|
||||
LDAPControl *ctrls[2];
|
||||
ctrls[0] = &c;
|
||||
ctrls[1] = NULL;
|
||||
if ( manageDSAit || noop ) {
|
||||
int err, i = 0;
|
||||
LDAPControl c1, c2;
|
||||
LDAPControl *ctrls[3];
|
||||
|
||||
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c.ldctl_value.bv_val = NULL;
|
||||
c.ldctl_value.bv_len = 0;
|
||||
c.ldctl_iscritical = manageDSAit > 1;
|
||||
if ( manageDSAit ) {
|
||||
ctrls[i++] = &c1;
|
||||
ctrls[i] = NULL;
|
||||
c1.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c1.ldctl_value.bv_val = NULL;
|
||||
c1.ldctl_value.bv_len = 0;
|
||||
c1.ldctl_iscritical = manageDSAit > 1;
|
||||
}
|
||||
|
||||
if ( noop ) {
|
||||
ctrls[i++] = &c2;
|
||||
ctrls[i] = NULL;
|
||||
|
||||
c2.ldctl_oid = LDAP_CONTROL_NOOP;
|
||||
c2.ldctl_value.bv_val = NULL;
|
||||
c2.ldctl_value.bv_len = 0;
|
||||
c2.ldctl_iscritical = noop > 1;
|
||||
}
|
||||
|
||||
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
|
||||
|
||||
if( err != LDAP_OPT_SUCCESS ) {
|
||||
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
|
||||
c.ldctl_iscritical ? "critical " : "" );
|
||||
if( c.ldctl_iscritical ) {
|
||||
exit( EXIT_FAILURE );
|
||||
fprintf( stderr, "Could not set %scontrols\n",
|
||||
(c1.ldctl_iscritical || c2.ldctl_iscritical)
|
||||
? "critical " : "" );
|
||||
if ( c1.ldctl_iscritical && c2.ldctl_iscritical ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ usage(const char *s)
|
|||
"Common options:\n"
|
||||
" -d level set LDAP debugging level to `level'\n"
|
||||
" -D binddn bind DN\n"
|
||||
" -e [!]<ctrl>[=<ctrlparam>] general controls (! indicates criticality)\n"
|
||||
" [!]manageDSAit (alternate form, see -M)\n"
|
||||
" [!]noop\n"
|
||||
" -f file read operations from `file'\n"
|
||||
" -h host LDAP server(s)\n"
|
||||
" -H URI LDAP Uniform Resource Indentifier(s)\n"
|
||||
|
|
@ -88,6 +91,9 @@ main( int argc, char *argv[] )
|
|||
int version = -1;
|
||||
int authmethod = -1;
|
||||
int manageDSAit = 0;
|
||||
int noop = 0;
|
||||
int crit;
|
||||
char *control, *cvalue;
|
||||
#ifdef HAVE_CYRUS_SASL
|
||||
unsigned sasl_flags = LDAP_SASL_AUTOMATIC;
|
||||
char *sasl_realm = NULL;
|
||||
|
|
@ -110,7 +116,7 @@ main( int argc, char *argv[] )
|
|||
prog = lutil_progname( "ldappasswd", argc, argv );
|
||||
|
||||
while( (i = getopt( argc, argv, "Aa:Ss:"
|
||||
"Cd:D:h:H:InO:p:QR:U:vw:WxX:Y:Z" )) != EOF )
|
||||
"Cd:D:e:h:H:InO:p:QR:U:vw:WxX:Y:Z" )) != EOF )
|
||||
{
|
||||
switch (i) {
|
||||
/* Password Options */
|
||||
|
|
@ -130,6 +136,31 @@ main( int argc, char *argv[] )
|
|||
}
|
||||
break;
|
||||
|
||||
case 'E': /* passwd controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -E !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
fprintf( stderr, "Invalid passwd control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
case 'S': /* prompt for user password */
|
||||
want_newpw++;
|
||||
break;
|
||||
|
|
@ -159,6 +190,56 @@ main( int argc, char *argv[] )
|
|||
}
|
||||
binddn = strdup( optarg );
|
||||
break;
|
||||
case 'e': /* general controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -e incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -e !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
|
||||
if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "manageDSAit: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
manageDSAit = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else if ( strcasecmp( control, "noop" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "noop: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
noop = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else {
|
||||
fprintf( stderr, "Invalid general control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
case 'h': /* ldap host */
|
||||
if( ldapuri != NULL ) {
|
||||
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
|
||||
|
|
@ -648,6 +729,42 @@ main( int argc, char *argv[] )
|
|||
}
|
||||
}
|
||||
|
||||
if ( manageDSAit || noop ) {
|
||||
int err, i = 0;
|
||||
LDAPControl c1, c2;
|
||||
LDAPControl *ctrls[3];
|
||||
|
||||
if ( manageDSAit ) {
|
||||
ctrls[i++] = &c1;
|
||||
ctrls[i] = NULL;
|
||||
c1.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c1.ldctl_value.bv_val = NULL;
|
||||
c1.ldctl_value.bv_len = 0;
|
||||
c1.ldctl_iscritical = manageDSAit > 1;
|
||||
}
|
||||
|
||||
if ( noop ) {
|
||||
ctrls[i++] = &c2;
|
||||
ctrls[i] = NULL;
|
||||
|
||||
c2.ldctl_oid = LDAP_CONTROL_NOOP;
|
||||
c2.ldctl_value.bv_val = NULL;
|
||||
c2.ldctl_value.bv_len = 0;
|
||||
c2.ldctl_iscritical = noop > 1;
|
||||
}
|
||||
|
||||
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
|
||||
|
||||
if( err != LDAP_OPT_SUCCESS ) {
|
||||
fprintf( stderr, "Could not set %scontrols\n",
|
||||
(c1.ldctl_iscritical || c2.ldctl_iscritical)
|
||||
? "critical " : "" );
|
||||
if ( c1.ldctl_iscritical && c2.ldctl_iscritical ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( user != NULL || oldpw != NULL || newpw != NULL ) {
|
||||
/* build change password control */
|
||||
BerElement *ber = ber_alloc_t( LBER_USE_DER );
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ usage( const char *s )
|
|||
" -a deref one of never (default), always, search, or find\n"
|
||||
" -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"
|
||||
" -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"
|
||||
|
|
@ -71,6 +73,9 @@ usage( const char *s )
|
|||
"Common options:\n"
|
||||
" -d level set LDAP debugging level to `level'\n"
|
||||
" -D binddn bind DN\n"
|
||||
" -e [!]<ctrl>[=<ctrlparam>] general controls (! indicates criticality)\n"
|
||||
" [!]manageDSAit (alternate form, see -M)\n"
|
||||
" [!]noop\n"
|
||||
" -f file read operations from `file'\n"
|
||||
" -h host LDAP server\n"
|
||||
" -H URI LDAP Uniform Resource Indentifier(s)\n"
|
||||
|
|
@ -181,20 +186,20 @@ main( int argc, char **argv )
|
|||
{
|
||||
char *infile, *filtpattern, **attrs = NULL, line[BUFSIZ];
|
||||
FILE *fp = NULL;
|
||||
int rc, i, first, scope, deref, attrsonly, manageDSAit;
|
||||
int rc, i, first, scope, deref, attrsonly, manageDSAit, noop, crit;
|
||||
int referrals, timelimit, sizelimit, debug;
|
||||
int authmethod, version, want_bindpw;
|
||||
LDAP *ld = NULL;
|
||||
int valuesReturnFilter;
|
||||
BerElement *ber = NULL;
|
||||
struct berval *bvalp = NULL;
|
||||
char *vrFilter = NULL, *control = NULL, *s;
|
||||
char *vrFilter = NULL, *control = NULL, *cvalue;
|
||||
char *pw_file = NULL;
|
||||
|
||||
|
||||
infile = NULL;
|
||||
debug = verbose = not = vals2tmp = referrals = valuesReturnFilter =
|
||||
attrsonly = manageDSAit = ldif = want_bindpw = 0;
|
||||
attrsonly = manageDSAit = noop = ldif = want_bindpw = 0;
|
||||
|
||||
prog = lutil_progname( "ldapsearch", argc, argv );
|
||||
|
||||
|
|
@ -228,7 +233,7 @@ main( int argc, char **argv )
|
|||
urlize( def_urlpre );
|
||||
|
||||
while (( i = getopt( argc, argv, "Aa:b:E:F:f:Ll:S:s:T:tuz:"
|
||||
"Cd:D:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z")) != EOF )
|
||||
"Cd:e:D:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z")) != EOF )
|
||||
{
|
||||
switch( i ) {
|
||||
/* Search Options */
|
||||
|
|
@ -252,45 +257,44 @@ main( int argc, char **argv )
|
|||
case 'b': /* search base */
|
||||
base = strdup( optarg );
|
||||
break;
|
||||
case 'f': /* input file */
|
||||
if( infile != NULL ) {
|
||||
fprintf( stderr, "%s: -f previously specified\n", prog );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
infile = strdup( optarg );
|
||||
break;
|
||||
case 'E': /* controls */
|
||||
case 'E': /* search controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -C incompatible with LDAPv%d\n",
|
||||
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* key/value pairs: -E foo=123,bar=567
|
||||
* [!]key[=value] parameters, e.g. -E !foo,bar=567
|
||||
*/
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (s = strchr( control, '=' )) == NULL ) {
|
||||
return EXIT_FAILURE;
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
|
||||
*s++ = '\0';
|
||||
if ( strcasecmp( control, "mv" ) == 0 ) {
|
||||
/* ValuesReturnFilter control */
|
||||
if (valuesReturnFilter!=0) {
|
||||
fprintf( stderr, "ValuesReturnFilter previously specified");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
valuesReturnFilter= 1 + crit;
|
||||
|
||||
if ( *s == '!' ){
|
||||
s++;
|
||||
valuesReturnFilter=2;
|
||||
} else {
|
||||
valuesReturnFilter=1;
|
||||
if ( cvalue == NULL ) {
|
||||
fprintf( stderr,
|
||||
"missing filter in ValuesReturnFilter control\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
vrFilter = s;
|
||||
vrFilter = cvalue;
|
||||
version = LDAP_VERSION3;
|
||||
break;
|
||||
|
||||
|
|
@ -299,7 +303,13 @@ main( int argc, char **argv )
|
|||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
case 'f': /* input file */
|
||||
if( infile != NULL ) {
|
||||
fprintf( stderr, "%s: -f previously specified\n", prog );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
infile = strdup( optarg );
|
||||
break;
|
||||
case 'F': /* uri prefix */
|
||||
if( urlpre ) free( urlpre );
|
||||
urlpre = strdup( optarg );
|
||||
|
|
@ -358,6 +368,56 @@ main( int argc, char **argv )
|
|||
}
|
||||
binddn = strdup( optarg );
|
||||
break;
|
||||
case 'e': /* general controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -e incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -e !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
|
||||
if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "manageDSAit: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
manageDSAit = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else if ( strcasecmp( control, "noop" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "noop: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
noop = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else {
|
||||
fprintf( stderr, "Invalid general control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
case 'h': /* ldap host */
|
||||
if( ldapuri != NULL ) {
|
||||
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
|
||||
|
|
@ -922,7 +982,7 @@ main( int argc, char **argv )
|
|||
|
||||
c2.ldctl_value=(*bvalp);
|
||||
}
|
||||
|
||||
|
||||
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
|
||||
|
||||
ber_bvfree(bvalp);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ usage(const char *s)
|
|||
"Common options:\n"
|
||||
" -d level set LDAP debugging level to `level'\n"
|
||||
" -D binddn bind DN\n"
|
||||
" -e [!]<ctrl>[=<ctrlparam>] general controls (! indicates criticality)\n"
|
||||
" [!]manageDSAit (alternate form, see -M)\n"
|
||||
" [!]noop\n"
|
||||
" -f file read operations from `file'\n"
|
||||
" -h host LDAP server(s)\n"
|
||||
" -H URI LDAP Uniform Resource Indentifier(s)\n"
|
||||
|
|
@ -90,6 +93,9 @@ main( int argc, char *argv[] )
|
|||
int use_tls = 0;
|
||||
int referrals = 0;
|
||||
LDAP *ld = NULL;
|
||||
int manageDSAit=0, noop=0;
|
||||
char *control, *cvalue;
|
||||
int crit;
|
||||
|
||||
int id, code = LDAP_OTHER;
|
||||
LDAPMessage *res;
|
||||
|
|
@ -100,9 +106,35 @@ main( int argc, char *argv[] )
|
|||
prog = lutil_progname( "ldapwhoami", argc, argv );
|
||||
|
||||
while( (i = getopt( argc, argv,
|
||||
"Cd:D:h:H:InO:p:QR:U:vw:WxX:y:Y:Z" )) != EOF )
|
||||
"Cd:D:e:h:H:InO:p:QR:U:vw:WxX:y:Y:Z" )) != EOF )
|
||||
{
|
||||
switch (i) {
|
||||
case 'E': /* whoami controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -E !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
fprintf( stderr, "Invalid whoami control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
|
||||
/* Common Options (including options we don't use) */
|
||||
case 'C':
|
||||
referrals++;
|
||||
|
|
@ -117,6 +149,56 @@ main( int argc, char *argv[] )
|
|||
}
|
||||
binddn = strdup( optarg );
|
||||
break;
|
||||
case 'e': /* general controls */
|
||||
if( version == LDAP_VERSION2 ) {
|
||||
fprintf( stderr, "%s: -e incompatible with LDAPv%d\n",
|
||||
prog, version );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* should be extended to support comma separated list of
|
||||
* [!]key[=value] parameters, e.g. -e !foo,bar=567
|
||||
*/
|
||||
|
||||
crit = 0;
|
||||
cvalue = NULL;
|
||||
if( optarg[0] == '!' ) {
|
||||
crit = 1;
|
||||
optarg++;
|
||||
}
|
||||
|
||||
control = strdup( optarg );
|
||||
if ( (cvalue = strchr( control, '=' )) != NULL ) {
|
||||
*cvalue++ = '\0';
|
||||
}
|
||||
|
||||
if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "manageDSAit: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
manageDSAit = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else if ( strcasecmp( control, "noop" ) == 0 ) {
|
||||
if( cvalue != NULL ) {
|
||||
fprintf( stderr, "noop: no control value expected" );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
noop = 1 + crit;
|
||||
free( control );
|
||||
break;
|
||||
|
||||
} else {
|
||||
fprintf( stderr, "Invalid general control name: %s\n", control );
|
||||
usage(prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
case 'h': /* ldap host */
|
||||
if( ldapuri != NULL ) {
|
||||
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
|
||||
|
|
@ -580,6 +662,42 @@ main( int argc, char *argv[] )
|
|||
goto skip;
|
||||
}
|
||||
|
||||
if ( manageDSAit || noop ) {
|
||||
int err, i = 0;
|
||||
LDAPControl c1, c2;
|
||||
LDAPControl *ctrls[3];
|
||||
|
||||
if ( manageDSAit ) {
|
||||
ctrls[i++] = &c1;
|
||||
ctrls[i] = NULL;
|
||||
c1.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
|
||||
c1.ldctl_value.bv_val = NULL;
|
||||
c1.ldctl_value.bv_len = 0;
|
||||
c1.ldctl_iscritical = manageDSAit > 1;
|
||||
}
|
||||
|
||||
if ( noop ) {
|
||||
ctrls[i++] = &c2;
|
||||
ctrls[i] = NULL;
|
||||
|
||||
c2.ldctl_oid = LDAP_CONTROL_NOOP;
|
||||
c2.ldctl_value.bv_val = NULL;
|
||||
c2.ldctl_value.bv_len = 0;
|
||||
c2.ldctl_iscritical = noop > 1;
|
||||
}
|
||||
|
||||
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
|
||||
|
||||
if( err != LDAP_OPT_SUCCESS ) {
|
||||
fprintf( stderr, "Could not set %scontrols\n",
|
||||
(c1.ldctl_iscritical || c2.ldctl_iscritical)
|
||||
? "critical " : "" );
|
||||
if ( c1.ldctl_iscritical && c2.ldctl_iscritical ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rc = ldap_extended_operation( ld,
|
||||
LDAP_EXOP_X_WHO_AM_I, NULL,
|
||||
NULL, NULL, &id );
|
||||
|
|
|
|||
145
clients/tools/ldapwhoami.dsp
Normal file
145
clients/tools/ldapwhoami.dsp
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
# Microsoft Developer Studio Project File - Name="ldapwhoami" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=ldapwhoami - Win32 Single Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "ldapwhoami.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "ldapwhoami.mak" CFG="ldapwhoami - Win32 Single Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "ldapwhoami - Win32 Release" (based on\
|
||||
"Win32 (x86) Console Application")
|
||||
!MESSAGE "ldapwhoami - Win32 Debug" (based on\
|
||||
"Win32 (x86) Console Application")
|
||||
!MESSAGE "ldapwhoami - Win32 Single Debug" (based on\
|
||||
"Win32 (x86) Console Application")
|
||||
!MESSAGE "ldapwhoami - Win32 Single Release" (based on\
|
||||
"Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "ldapwhoami - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "ldappass"
|
||||
# PROP BASE Intermediate_Dir "ldappass"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "..\..\Release"
|
||||
# PROP Intermediate_Dir "..\..\Release\ldapwhoami"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 sasl.lib libsasl.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ldapwhoami - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "ldappas0"
|
||||
# PROP BASE Intermediate_Dir "ldappas0"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "..\..\Debug"
|
||||
# PROP Intermediate_Dir "..\..\Debug\ldapwhoami"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 libsasl.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ldapwhoami - Win32 Single Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Single Debug"
|
||||
# PROP BASE Intermediate_Dir "Single Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "..\..\SDebug"
|
||||
# PROP Intermediate_Dir "..\..\SDebug\ldapwhoami"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 libsasl.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\SDebug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ldapwhoami - Win32 Single Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Single Release"
|
||||
# PROP BASE Intermediate_Dir "Single Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "..\..\SRelease"
|
||||
# PROP Intermediate_Dir "..\..\SRelease\ldapwhoami"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 sasl.lib libsasl.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\SRelease"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "ldapwhoami - Win32 Release"
|
||||
# Name "ldapwhoami - Win32 Debug"
|
||||
# Name "ldapwhoami - Win32 Single Debug"
|
||||
# Name "ldapwhoami - Win32 Single Release"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ldapwhoami.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
Loading…
Reference in a new issue