op->o_sasl_ssf = sasl_ssf;
if ( !BER_BVISNULL( &authcID ) ) {
+ if ( !BER_BVISNULL( &authcDN ) ) {
+ fprintf( stderr, "both authcID=\"%s\" "
+ "and authcDN=\"%s\" provided\n",
+ authcID.bv_val, authcDN.bv_val );
+ rc = 1;
+ goto destroy;
+ }
+
rc = slap_sasl_getdn( &conn, op, &authcID, NULL,
&authcDN, SLAP_GETDN_AUTHCID );
if ( rc != LDAP_SUCCESS ) {
- fprintf( stderr, "ID: <%s> check failed %d (%s)\n",
+ fprintf( stderr, "authcID: <%s> check failed %d (%s)\n",
authcID.bv_val, rc,
ldap_err2string( rc ) );
rc = 1;
authcDN = ndn;
}
+ if ( !BER_BVISNULL( &authzID ) ) {
+ if ( !BER_BVISNULL( &authzDN ) ) {
+ fprintf( stderr, "both authzID=\"%s\" "
+ "and authzDN=\"%s\" provided\n",
+ authzID.bv_val, authzDN.bv_val );
+ rc = 1;
+ goto destroy;
+ }
+
+ rc = slap_sasl_getdn( &conn, op, &authzID, NULL,
+ &authzDN, SLAP_GETDN_AUTHZID );
+ if ( rc != LDAP_SUCCESS ) {
+ fprintf( stderr, "authzID: <%s> check failed %d (%s)\n",
+ authzID.bv_val, rc,
+ ldap_err2string( rc ) );
+ rc = 1;
+ goto destroy;
+ }
+
+ } else if ( !BER_BVISNULL( &authzDN ) ) {
+ struct berval ndn;
+
+ rc = dnNormalize( 0, NULL, NULL, &authzDN, &ndn, NULL );
+ if ( rc != LDAP_SUCCESS ) {
+ fprintf( stderr, "autchDN=\"%s\" normalization failed %d (%s)\n",
+ authzDN.bv_val, rc,
+ ldap_err2string( rc ) );
+ rc = 1;
+ goto destroy;
+ }
+ ch_free( authzDN.bv_val );
+ authzDN = ndn;
+ }
+
if ( !BER_BVISNULL( &authcDN ) ) {
- fprintf( stderr, "DN: \"%s\"\n", authcDN.bv_val );
+ fprintf( stderr, "authcDN: \"%s\"\n", authcDN.bv_val );
+ }
+
+ if ( !BER_BVISNULL( &authzDN ) ) {
+ fprintf( stderr, "authzDN: \"%s\"\n", authzDN.bv_val );
}
assert( !BER_BVISNULL( &baseDN ) );
}
op->o_bd = be;
+ if ( !BER_BVISNULL( &authzDN ) ) {
+ op->o_dn = authzDN;
+ op->o_ndn = authzDN;
+ }
if ( !BER_BVISNULL( &authcDN ) ) {
- op->o_dn = authcDN;
- op->o_ndn = authcDN;
+ op->o_conn->c_dn = authcDN;
+ op->o_conn->c_ndn = authcDN;
}
- if ( !dryrun ) {
+ if ( !dryrun && be ) {
ID id;
if ( !be->be_entry_open ||
destroy:;
ber_memfree( e.e_name.bv_val );
ber_memfree( e.e_nname.bv_val );
- if ( !dryrun ) {
+ if ( !dryrun && be ) {
if ( ep != &e ) {
be_entry_release_r( op, ep );
}
switch( tool ) {
case SLAPACL:
- options = "\n\t[-U authcID | -D authcDN]"
- " -b DN -o <var>[=<val>] [-u]"
- "\n\t[attr[/access][:value]] [...]\n";
+ options = "\n\t[-U authcID | -D authcDN] [-X authzID | -o authzDN=<DN>]"
+ "\n\t-b DN -o <var>[=<val>] [-u] [attr[/access][:value]] [...]\n";
break;
case SLAPADD:
} else if ( strncasecmp( optarg, "sasl_ssf", len ) == 0 ) {
sasl_ssf = atoi( p );
+ } else if ( strncasecmp( optarg, "authzDN", len ) == 0 ) {
+ ber_str2bv( p, 0, 1, &authzDN );
+
} else {
return -1;
}
break;
case SLAPACL:
- options = "b:D:d:f:F:o:uU:v";
+ options = "b:D:d:f:F:o:uU:vX:";
mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
break;
Filter *tv_filter;
struct berval tv_sub_ndn;
FILE *tv_ldiffp;
- struct berval tv_authcDN;
struct berval tv_baseDN;
+ struct berval tv_authcDN;
+ struct berval tv_authzDN;
struct berval tv_authcID;
struct berval tv_authzID;
struct berval tv_mech;
#define filter tool_globals.tv_filter
#define sub_ndn tool_globals.tv_sub_ndn
#define ldiffp tool_globals.tv_ldiffp
-#define authcDN tool_globals.tv_authcDN
#define baseDN tool_globals.tv_baseDN
+#define authcDN tool_globals.tv_authcDN
+#define authzDN tool_globals.tv_authzDN
#define authcID tool_globals.tv_authcID
#define authzID tool_globals.tv_authzID
#define mech tool_globals.tv_mech