1
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3
* Copyright 2004-2008 The OpenLDAP Foundation.
4
* Portions Copyright 2004 Pierangelo Masarati.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted only as authorized by the OpenLDAP
11
* A copy of this license is available in file LICENSE in the
12
* top-level directory of the distribution or, alternatively, at
13
* <http://www.OpenLDAP.org/license.html>.
16
* This work was initially developed by Pierangelo Masarati for inclusion
17
* in OpenLDAP Software.
24
#include <ac/stdlib.h>
27
#include <ac/string.h>
28
#include <ac/socket.h>
29
#include <ac/unistd.h>
35
#include "slapcommon.h"
38
slapdn( int argc, char **argv )
41
const char *progname = "slapdn";
43
slap_tool_init( progname, SLAPDN, argc, argv );
45
argv = &argv[ optind ];
48
for ( ; argc--; argv++ ) {
53
ber_str2bv( argv[ 0 ], 0, 0, &dn );
56
case SLAP_TOOL_LDAPDN_PRETTY:
57
rc = dnPretty( NULL, &dn, &pdn, NULL );
60
case SLAP_TOOL_LDAPDN_NORMAL:
61
rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
65
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
69
if ( rc != LDAP_SUCCESS ) {
70
fprintf( stderr, "DN: <%s> check failed %d (%s)\n",
72
ldap_err2string( rc ) );
73
if ( !continuemode ) {
80
case SLAP_TOOL_LDAPDN_PRETTY:
81
printf( "%s\n", pdn.bv_val );
84
case SLAP_TOOL_LDAPDN_NORMAL:
85
printf( "%s\n", ndn.bv_val );
89
printf( "DN: <%s> check succeeded\n"
93
ndn.bv_val, pdn.bv_val );
97
ch_free( ndn.bv_val );
98
ch_free( pdn.bv_val );