|
|
|
@ -45,18 +45,15 @@ if (($ip eq 'disabled') || ($alias eq 'disabled')){ |
|
|
|
|
|
|
|
|
|
my $l = $c->get('ldap'); |
|
|
|
|
my $status = $l->prop('status') || "disabled"; |
|
|
|
|
unless ($status eq "enabled" ) |
|
|
|
|
{ |
|
|
|
|
unless ($status eq "enabled" ){ |
|
|
|
|
warn "Not running action script $0, LDAP service not enabled!\n"; |
|
|
|
|
exit(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
my $hostname = $c->get('SystemName') |
|
|
|
|
|| die("Couldn't determine system name"); |
|
|
|
|
my $hostname = $c->get('SystemName') || die("Couldn't determine system name"); |
|
|
|
|
$hostname = $hostname->value; |
|
|
|
|
|
|
|
|
|
my $domain = $c->get('DomainName') |
|
|
|
|
|| die("Couldn't determine domain name"); |
|
|
|
|
my $domain = $c->get('DomainName') || die("Couldn't determine domain name"); |
|
|
|
|
$domain = $domain->value; |
|
|
|
|
|
|
|
|
|
my @accounts; |
|
|
|
@ -64,18 +61,15 @@ my $account; |
|
|
|
|
my $event = shift || die "Event name must be specified"; |
|
|
|
|
if ($event eq 'ldap-update' or |
|
|
|
|
$event eq 'bootstrap-ldap-save' or |
|
|
|
|
$event =~ m/(pseudonym)\-(create|modify|delete)/) |
|
|
|
|
{ |
|
|
|
|
$event =~ m/(pseudonym)\-(create|modify|delete)/){ |
|
|
|
|
@accounts = ($a->users,$a->groups); |
|
|
|
|
push(@accounts, $a->get('admin')); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
else{ |
|
|
|
|
my @name = @ARGV; |
|
|
|
|
die "Account name argument missing." unless scalar (@name) >= 1; |
|
|
|
|
|
|
|
|
|
foreach my $name (@name) |
|
|
|
|
{ |
|
|
|
|
foreach my $name (@name){ |
|
|
|
|
$account = $a->get($name); |
|
|
|
|
die "Account $name not found.\n" unless defined $account; |
|
|
|
|
|
|
|
|
@ -95,8 +89,7 @@ $ldap->bind( |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
my $result; |
|
|
|
|
foreach my $acct (@accounts) |
|
|
|
|
{ |
|
|
|
|
foreach my $acct (@accounts){ |
|
|
|
|
my $key = $acct->key; |
|
|
|
|
|
|
|
|
|
my @pseudo = ("$key"); |
|
|
|
@ -136,6 +129,17 @@ foreach my $acct (@accounts) |
|
|
|
|
$ou = "Groups"; |
|
|
|
|
$dn = "cn"; |
|
|
|
|
} |
|
|
|
|
$result = $ldap->search(base => "ou=$ou,$base", |
|
|
|
|
filter => "$dn=$key"); |
|
|
|
|
$result->code && warn "failed to search for entry $dn=$key,ou=$ou,$base: ", $result->error; |
|
|
|
|
my @mails = (); |
|
|
|
|
foreach my $entry ($result->all_entries()){ |
|
|
|
|
push @mails, $entry->get_value('mail'); |
|
|
|
|
} |
|
|
|
|
my $alias = join('\0', sort @alias); |
|
|
|
|
my $mails = join('\0', sort @mails); |
|
|
|
|
|
|
|
|
|
unless ($alias eq $mails){ |
|
|
|
|
$result = $ldap->modify( |
|
|
|
|
"$dn=$key,ou=$ou,$base", |
|
|
|
|
replace => { |
|
|
|
@ -144,6 +148,8 @@ foreach my $acct (@accounts) |
|
|
|
|
); |
|
|
|
|
$result->code && warn "failed to modify entry $dn=$key,ou=$ou,$base: ", $result->error; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ldap->unbind; |
|
|
|
|
|
|
|
|
|