aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-04-18 03:23:44 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-04-18 03:23:44 +0200
commitc7cc448801f8b6f10cdd0d86568180687173f03e (patch)
tree62e9d79300f53d85681d653b043f9401d480432d /lib/Fripost
parentbba3f61c1403d09ad2d38a0fab153f87877a1722 (diff)
wibble
Diffstat (limited to 'lib/Fripost')
-rw-r--r--lib/Fripost/Schema/Search.pm7
-rw-r--r--lib/Fripost/Schema/Type/Alias.pm20
-rw-r--r--lib/Fripost/Schema/Type/User.pm4
3 files changed, 17 insertions, 14 deletions
diff --git a/lib/Fripost/Schema/Search.pm b/lib/Fripost/Schema/Search.pm
index 30d92d6..7c0ece6 100644
--- a/lib/Fripost/Schema/Search.pm
+++ b/lib/Fripost/Schema/Search.pm
@@ -51,11 +51,8 @@ sub _domainEntry {
my $entry = shift;
my %domain;
&_get_values( $entry, \%domain, 'domain', 'dc');
- &_get_values( $entry, \%domain, 'isActive');
- my $parent = &_get_dn($entry)->[1];
- unless ($parent eq 'ou=domains') {
- $domain{owner} = (split /=/, $parent, 2)[1];
- }
+ map { &_get_values($entry, \%domain, $_) }
+ qw /isActive owner/;
return \%domain;
}
diff --git a/lib/Fripost/Schema/Type/Alias.pm b/lib/Fripost/Schema/Type/Alias.pm
index fa78d6f..7949b4b 100644
--- a/lib/Fripost/Schema/Type/Alias.pm
+++ b/lib/Fripost/Schema/Type/Alias.pm
@@ -14,10 +14,15 @@ our $VERSION = '0.01';
# alias is given, returns all aliases.
# Filters on values of both keys `address' and `goto' (unless they are
# undefined).
+# An extra key `domain' can be given to scope the search on aliases for
+# this domain only.
sub search {
my $self = shift;
- my $base = $self->{_options}->{base_dn};
+ my $base = join ',', ( 'ou=domains'
+ , $self->{_options}->{base_dn} );
+ $base = 'dc='.$_[0]->{domain} .','. $base
+ if defined $_[0]->{domain};
my @filters = ('(ObjectClass=virtualAliases)');
push @filters, '(mailLocalAddress=' .$_[0]->{address}. ')'
@@ -54,15 +59,15 @@ sub add {
"' targetting to itself.\n"
if $alias->{address} eq $alias->{goto};
+ my $domain = (split /\@/, $alias->{address}, 2)[1];
my $base = join ',', ( 'mailTarget='.$alias->{goto}
- , 'dc='. (split /\@/, $alias->{address}, 2)[1]
+ , 'dc='. $domain
, 'ou=domains'
, $self->{_options}->{base_dn} );
- my @attrs = ( mailLocalAddress => $alias->{address}
- , isActive => $alias->{isActive} );
+ my @attrs = ( mailLocalAddress => $alias->{address} );
my $res;
- if ($self->search($alias)->count) {
+ if ($self->search({ goto => $alias->{goto}, domain => $domain })->count) {
$res = $self->{_ldap}->modify( $base, add => [ @attrs ] );
}
else {
@@ -70,8 +75,9 @@ sub add {
attrs => [ mailTarget => $alias->{goto}
, objectClass => [ 'top',
'inetLocalMailRecipient',
- 'virtualAliases' ],
- @attrs
+ 'virtualAliases' ]
+ , @attrs
+ , isActive => $alias->{isActive}
]
);
}
diff --git a/lib/Fripost/Schema/Type/User.pm b/lib/Fripost/Schema/Type/User.pm
index 09c3aa0..544687c 100644
--- a/lib/Fripost/Schema/Type/User.pm
+++ b/lib/Fripost/Schema/Type/User.pm
@@ -19,8 +19,8 @@ sub search {
my $base = join ',', ('ou=mailboxes',$self->{_options}->{base_dn});
my $filter = "(ObjectClass=virtualMailbox)";
- $filter = "(&" .$filter. "(uid=" .$_[0]. ")" .")"
- if defined $_[0];
+ $filter = "(&" .$filter. "(uid=" .$_[0]->{username}. ")" .")"
+ if defined $_[0]->{username};
my $res = $self->{_ldap}->search(
base => $base,