Commit 8e19437d authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

allow slapdn to return the DN in pretty/normal only mode, without diagnostics,...

allow slapdn to return the DN in pretty/normal only mode, without diagnostics, to be used as filter (should allow reading from stdin as well)
parent ae3f784d
......@@ -74,7 +74,7 @@ usage( int tool, const char *progname )
break;
case SLAPDN:
options = " DN [...]\n";
options = "\n\t[-N | -P] DN [...]\n";
break;
case SLAPINDEX:
......@@ -194,7 +194,7 @@ slap_tool_init(
break;
case SLAPDN:
options = "d:f:F:v";
options = "d:f:F:NPv";
mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
break;
......@@ -262,6 +262,13 @@ slap_tool_init(
ber_str2bv( optarg, 0, 0, &mech );
break;
case 'N':
if ( dn_mode && dn_mode != SLAP_TOOL_LDAPDN_NORMAL ) {
usage( tool, progname );
}
dn_mode = SLAP_TOOL_LDAPDN_NORMAL;
break;
case 'n': /* which config file db to index */
dbnum = atoi( optarg );
break;
......@@ -272,6 +279,13 @@ slap_tool_init(
}
break;
case 'P':
if ( dn_mode && dn_mode != SLAP_TOOL_LDAPDN_PRETTY ) {
usage( tool, progname );
}
dn_mode = SLAP_TOOL_LDAPDN_PRETTY;
break;
case 'q': /* turn on quick */
mode |= SLAP_TOOL_QUICK;
break;
......
......@@ -56,6 +56,7 @@ typedef struct tool_vars {
slap_ssf_t tv_transport_ssf;
slap_ssf_t tv_tls_ssf;
slap_ssf_t tv_sasl_ssf;
unsigned tv_dn_mode;
} tool_vars;
extern tool_vars tool_globals;
......@@ -83,6 +84,9 @@ extern tool_vars tool_globals;
#define transport_ssf tool_globals.tv_transport_ssf
#define tls_ssf tool_globals.tv_tls_ssf
#define sasl_ssf tool_globals.tv_sasl_ssf
#define dn_mode tool_globals.tv_dn_mode
#define SLAP_TOOL_LDAPDN_PRETTY SLAP_LDAPDN_PRETTY
#define SLAP_TOOL_LDAPDN_NORMAL (SLAP_LDAPDN_PRETTY << 1)
void slap_tool_init LDAP_P((
const char* name,
......
......@@ -62,11 +62,24 @@ slapdn( int argc, char **argv )
}
} else {
fprintf( stderr, "DN: <%s> check succeeded\n"
"normalized: <%s>\n"
"pretty: <%s>\n",
dn.bv_val,
ndn.bv_val, pdn.bv_val );
switch ( dn_mode ) {
case SLAP_TOOL_LDAPDN_PRETTY:
printf( "%s\n", pdn.bv_val );
break;
case SLAP_TOOL_LDAPDN_NORMAL:
printf( "%s\n", ndn.bv_val );
break;
default:
printf( "DN: <%s> check succeeded\n"
"normalized: <%s>\n"
"pretty: <%s>\n",
dn.bv_val,
ndn.bv_val, pdn.bv_val );
break;
}
ch_free( ndn.bv_val );
ch_free( pdn.bv_val );
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment