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 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts; |
---|
6 | use Getopt::Long; |
---|
7 | use Pod::Usage; |
---|
8 | use 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 | |
---|
24 | Use this configuration file instead of the default one. |
---|
25 | |
---|
26 | =item -b|--base basename |
---|
27 | |
---|
28 | Query this specific base instead of the default one. |
---|
29 | |
---|
30 | =item -s|--sync syncname |
---|
31 | |
---|
32 | Use this synchronisation |
---|
33 | |
---|
34 | =item -o|--otype otype |
---|
35 | |
---|
36 | Modify object having type 'otype', default is user |
---|
37 | |
---|
38 | =item -t|--test |
---|
39 | |
---|
40 | Don't change the password but check its validity using CrackLib. |
---|
41 | |
---|
42 | =back |
---|
43 | |
---|
44 | =cut |
---|
45 | |
---|
46 | GetOptions( |
---|
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 | |
---|
55 | if (@ARGV != 2) { pod2usage(); } |
---|
56 | |
---|
57 | $otype ||= 'user'; |
---|
58 | |
---|
59 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
60 | my $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 | |
---|
65 | my $obj = $labase->get_object($otype, $ARGV[0]) or do { |
---|
66 | die "Object $otype $ARGV[0] not found\n"; |
---|
67 | }; |
---|
68 | |
---|
69 | if (!$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.