1 |
package VLDAP::Server; |
package LDAP::Virtual; |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use warnings; |
use warnings; |
24 |
|
|
25 |
=head1 NAME |
=head1 NAME |
26 |
|
|
27 |
VLDAP::Server |
LDAP::Virtual |
28 |
|
|
29 |
=cut |
=cut |
30 |
|
|
36 |
|
|
37 |
=head2 run |
=head2 run |
38 |
|
|
39 |
my $pid = VLDAP::Server->run({ port => 1389, fork => 0 }); |
my $pid = LDAP::Virtual->run({ port => 1389, fork => 0 }); |
40 |
|
|
41 |
=cut |
=cut |
42 |
|
|
44 |
our $cache; |
our $cache; |
45 |
|
|
46 |
sub cache { |
sub cache { |
47 |
return $cache if $cache; |
return $cache; |
|
$cache = new A3C::Cache->new({ instance => '', dir => 'ldap' }); |
|
48 |
} |
} |
49 |
|
|
50 |
sub run { |
sub run { |
81 |
# let's create a new socket |
# let's create a new socket |
82 |
my $psock = $sock->accept; |
my $psock = $sock->accept; |
83 |
$sel->add($psock); |
$sel->add($psock); |
84 |
$Handlers{*$psock} = VLDAP::Server->new($psock); |
$Handlers{*$psock} = LDAP::Virtual->new($psock); |
85 |
} else { |
} else { |
86 |
my $result = $Handlers{*$fh}->handle; |
my $result = $Handlers{*$fh}->handle; |
87 |
if ($result) { |
if ($result) { |
97 |
|
|
98 |
=head2 stop |
=head2 stop |
99 |
|
|
100 |
my $stopped_pids = VLDAP::Server->stop; |
my $stopped_pids = LDAP::Virtual->stop; |
101 |
|
|
102 |
=cut |
=cut |
103 |
|
|
157 |
#$msg = $self->{upstream}->unbind; |
#$msg = $self->{upstream}->unbind; |
158 |
#warn "# unbind msg = ",dump( $msg ); |
#warn "# unbind msg = ",dump( $msg ); |
159 |
|
|
160 |
$msg = $self->{upstream}->bind( |
my $bind; |
161 |
dn => $req->{name}, |
$bind->{dn} = $req->{name} if $req->{name}; |
162 |
password => $req->{authentication}->{simple} |
$bind->{password} = $req->{authentication}->{simple} if $req->{authentication}->{simple}; |
163 |
); |
warn "# bind ",dump( $bind ); |
164 |
|
$msg = $self->{upstream}->bind( %$bind ); |
165 |
|
|
166 |
#warn "# bind msg = ",dump( $msg ); |
#warn "# bind msg = ",dump( $msg ); |
167 |
if ( $msg->code != LDAP_SUCCESS ) { |
if ( $msg->code != LDAP_SUCCESS ) { |
240 |
|
|
241 |
warn "## entries = ",dump( @entries ); |
warn "## entries = ",dump( @entries ); |
242 |
|
|
243 |
$self->cache->write_cache( \@entries, uri_escape( $filter )); |
# $self->cache->write_cache( \@entries, uri_escape( $filter )); |
244 |
|
|
245 |
return RESULT_OK, @entries; |
return RESULT_OK, @entries; |
246 |
} |
} |