1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
package Fripost::Schema;
=head1 NAME
Schema.pm -
=cut
=head1 DESCRIPTION
Schema.pm abstracts the LDAP schema definition and provides methods to
add, list or delete virtual domains, users, aliases or lists.
=cut
use 5.010_000;
use strict;
use warnings;
use utf8;
use parent 'Fripost::Schema::Auth';
use Net::LDAP;
use Authen::SASL;
use Fripost::Schema::Util qw/canonical_dn ldap_explode_dn split_addr/;
use Fripost::Schema::Domain;
use Fripost::Schema::User;
use Fripost::Schema::Alias;
use Fripost::Schema::List;
use Fripost::Schema::Local;
use Net::IDN::Encode 'email_to_ascii';
=head1 METHODS
=over 4
=item B<domain>
Bless the object to C<Fripost::Schema::Domain>, to access
domain-specific methods.
=cut
sub domain { bless shift, 'Fripost::Schema::Domain'; }
=item B<user>
Bless the object to C<Fripost::Schema::User>, to access
user-specific methods.
=cut
sub user { bless shift, 'Fripost::Schema::User'; }
=item B<alias>
Bless the object to C<Fripost::Schema::Alias>, to access
alias-specific methods.
=cut
sub alias { bless shift, 'Fripost::Schema::Alias'; }
=item B<list>
Bless the object to C<Fripost::Schema::List>, to access
list-specific methods.
=cut
sub list { bless shift, 'Fripost::Schema::List'; }
=item B<local>
Bless the object to C<Fripost::Schema::Local>, to access
local-specific (users, aliases and lists) methods.
=cut
sub local { bless shift, 'Fripost::Schema::Local'; }
=back
=head1 AUTHOR
Guilhem Moulin C<< <guilhem at fripost.org> >>
=head1 COPYRIGHT
Copyright 2012,2013 Guilhem Moulin.
=head1 LICENSE
This program is free software; you can redistribute it and/or modify it
under the same terms as perl itself.
=cut
sub _dn2fvu {
my $self = shift;
my $dn = ldap_explode_dn(shift);
return '@'. $dn->[0]->{fvd} if exists $dn->[0]->{fvd};
return $dn->[0]->{fvu} .'@'. $dn->[1]->{fvd};
}
sub _fvu2dn {
my $self = shift;
my $email = shift;
my ($l,$d) = split_addr($email);
my @dn = ({fvd => $d}, @{$self->suffix});
unshift @dn, {fvu => $l} if defined $l and $l ne '';
canonical_dn( @dn );
}
1;
__END__
|