14 |
use base qw(Net::LDAP::Server); |
use base qw(Net::LDAP::Server); |
15 |
use fields qw(upstream); |
use fields qw(upstream); |
16 |
|
|
17 |
|
use Net::LDAP; |
18 |
|
|
19 |
use URI::Escape; # uri_escape |
use URI::Escape; # uri_escape |
20 |
use IO::Socket::INET; |
use IO::Socket::INET; |
21 |
use IO::Select; |
use IO::Select; |
24 |
|
|
25 |
=head1 NAME |
=head1 NAME |
26 |
|
|
27 |
A3C::LDAP::Server |
VLDAP::Server |
28 |
|
|
29 |
=cut |
=cut |
30 |
|
|
31 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
32 |
|
|
33 |
Provide LDAP server functionality for L<A3C> somewhat similar to C<slapo-rwm> |
Provide LDAP server functionality somewhat similar to C<slapo-rwm> |
34 |
|
|
35 |
=head1 METHODS |
=head1 METHODS |
36 |
|
|
37 |
=head2 run |
=head2 run |
38 |
|
|
39 |
my $pid = A3C::LDAP::Server->run({ port => 1389, fork => 0 }); |
my $pid = VLDAP::Server->run({ port => 1389, fork => 0 }); |
40 |
|
|
41 |
=cut |
=cut |
42 |
|
|
82 |
# let's create a new socket |
# let's create a new socket |
83 |
my $psock = $sock->accept; |
my $psock = $sock->accept; |
84 |
$sel->add($psock); |
$sel->add($psock); |
85 |
$Handlers{*$psock} = A3C::LDAP::Server->new($psock); |
$Handlers{*$psock} = VLDAP::Server->new($psock); |
86 |
} else { |
} else { |
87 |
my $result = $Handlers{*$fh}->handle; |
my $result = $Handlers{*$fh}->handle; |
88 |
if ($result) { |
if ($result) { |
98 |
|
|
99 |
=head2 stop |
=head2 stop |
100 |
|
|
101 |
my $stopped_pids = A3C::LDAP::Server->stop; |
my $stopped_pids = VLDAP::Server->stop; |
102 |
|
|
103 |
=cut |
=cut |
104 |
|
|
143 |
resultCode => LDAP_STRONG_AUTH_NOT_SUPPORTED, |
resultCode => LDAP_STRONG_AUTH_NOT_SUPPORTED, |
144 |
}; |
}; |
145 |
|
|
146 |
$self->{upstream} ||= A3C::LDAP->new->ldap or return { |
$self->{upstream} ||= Net::LDAP->new( 'ldaps://ldap.ffzg.hr/' ) or return { |
147 |
matchedDN => '', |
matchedDN => '', |
148 |
errorMessage => $@, |
errorMessage => $@, |
149 |
resultCode => LDAP_UNAVAILABLE, |
resultCode => LDAP_UNAVAILABLE, |
150 |
}; |
}; |
151 |
|
|
152 |
# warn "## upstream = ",dump( $self->{upstream} ); |
warn "## upstream = ",dump( $self->{upstream} ); |
153 |
# warn "upstream not Net::LDAP but ",ref($self->{upstream}) unless ref($self->{upstream}) eq 'Net::LDAP'; |
warn "upstream not Net::LDAP but ",ref($self->{upstream}) unless ref($self->{upstream}) eq 'Net::LDAP'; |
154 |
|
|
155 |
my $msg; |
my $msg; |
156 |
|
|
157 |
# FIXME we would need to unbind because A3C::LDAP binds us automatically, but that doesn't really work |
# FIXME we would need to unbind because VLDAP binds us automatically, but that doesn't really work |
158 |
#$msg = $self->{upstream}->unbind; |
#$msg = $self->{upstream}->unbind; |
159 |
#warn "# unbind msg = ",dump( $msg ); |
#warn "# unbind msg = ",dump( $msg ); |
160 |
|
|