/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* ldapmodrdn.c - generic program to modify an entry's RDN using LDAP */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <ctype.h>
#include <lber.h>
#include <ldap.h>
#include <locale.h>
#include "ldaptool.h"
int remove_oldrdn);
static void usage( void )
{
ldaptool_common_usage( 0 );
}
int
{
int haverdn = 0;
contoper = remove_oldrdn = 0;
else
++myname;
if ( optind == -1 ) {
usage();
}
if ( ldaptool_fp == NULL ) {
ldaptool_fp = stdin;
}
havedn = 0;
{
{
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
{
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
{
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
++havedn;
}
{
{
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
{
perror( "strdup" );
exit( 1 );
}
++havedn;
}
{
usage();
exit( 1 );
}
ld = ldaptool_ldap_init (0);
if ( !ldaptool_not ) {
}
ldaptool_bind( ld );
rc = 0;
if (havedn)
{
}
{
/*
* The format of the file is one of the following:
* dn
* rdn
* newsuperior
* <blank lines...>
* OR
* dn
* rdn
* <blank lines...>
* both types of sequences can be found in the file
*/
break;
{
if ( haverdn ) /* first type of sequence */
{
{
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
{
L_newParent = NULL;
}
haverdn = 0;
}
else if ( havedn ) /* have DN, get RDN */
{
{
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
havedn = 0;
++haverdn;
}
else if ( !havedn ) /* don't have DN yet */
{
{
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
++havedn;
}
}
else
{
if ( haverdn ) /* second type of sequence */
{
haverdn = 0;
}
}
}
{
haverdn = 0;
}
ldaptool_cleanup( ld );
}
static void
{
switch( option ) {
case 'c': /* continuous operation mode */
++contoper;
break;
case 'r': /* remove old RDN */
break;
default:
usage();
}
}
static int
{
if ( ldaptool_verbose )
if ( !ldaptool_not )
{
if ( rc != LDAP_SUCCESS )
else if ( ldaptool_verbose )
}
putchar('\n');
return( rc );
}