source: LATMOS-Accounts/bin/la-rename @ 715

Last change on this file since 715 was 715, checked in by nanardon, 14 years ago
  • la-passwd set password in all base, not only one (must have been case for long time)
  • add tools la-rename to rename an object in all base and avoid delete/creation
  • many fix in syncaccess, add some functions
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8use Term::ReadKey;
9
10=head1 NAME
11
12    la-rename - rename object in database
13
14=head1 SYNOPSIS
15
16    la-rename [options] oid newoid
17
18=head1 OPTIONS
19
20=over 4
21
22=item -c|--config configfile
23
24Use this configuration file instead of the default one.
25
26=item -b|--base basename
27
28Query this specific base instead of the default one.
29
30=item -s|--sync syncname
31
32Use this synchronisation
33
34=item -o|--otype otype
35
36Modify object having type 'otype', default is user
37
38=item -t|--test
39
40Don't change the password but check its validity using CrackLib.
41
42=back
43
44=cut
45
46GetOptions(
47    'c|config=s' => \my $config,
48    'b|base=s'   => \my $base,
49    't|test'     => \my $test,
50    's|sync=s'   => \my $sync,
51    'o|otype=s'  => \my $otype,
52    'help'       => sub { pod2usage(0) },
53) or pod2usage();
54
55if (@ARGV != 2) { pod2usage(); }
56
57$otype ||= 'user';
58
59my $LA = LATMOS::Accounts->new($config, noacl => 1);
60my $labase = $base ? $LA->base($base) : $LA->sync_access($sync);
61$labase && $labase->load or die "Cannot load base\n";
62
63$labase->wexported(1);
64
65my $obj = $labase->get_object($otype, $ARGV[0]) or do {
66    die "Object $otype $ARGV[0] not found\n";
67};
68
69if (!$labase->rename_object($otype, @ARGV)) {
70    die "Error while renaming $otype $ARGV[0] to $ARGV[1]\n";
71}
72
73$labase->commit;
Note: See TracBrowser for help on using the repository browser.