/[virtual-ldap]/lib/LDAP/Virtual.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/LDAP/Virtual.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

lib/VLDAP/Server.pm revision 2 by dpavlin, Sat Mar 14 13:45:20 2009 UTC lib/LDAP/Virtual.pm revision 31 by dpavlin, Mon Mar 23 20:24:46 2009 UTC
# Line 1  Line 1 
1  package VLDAP::Server;  package LDAP::Virtual;
2    
3  use strict;  use strict;
4  use warnings;  use warnings;
# Line 20  use URI::Escape;       # uri_escape Line 20  use URI::Escape;       # uri_escape
20  use IO::Socket::INET;  use IO::Socket::INET;
21  use IO::Select;  use IO::Select;
22    
23    use YAML qw/DumpFile/;
24    
25  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
26    
27  =head1 NAME  =head1 NAME
28    
29  VLDAP::Server  LDAP::Virtual
30    
31  =cut  =cut
32    
# Line 36  Provide LDAP server functionality somewh Line 38  Provide LDAP server functionality somewh
38    
39  =head2 run  =head2 run
40    
41    my $pid = VLDAP::Server->run({ port => 1389, fork => 0 });    my $pid = LDAP::Virtual->run({ port => 1389, fork => 0 });
42    
43  =cut  =cut
44    
45  our $pids;  our $pids;
 our $cache;  
   
 sub cache {  
         return $cache if $cache;  
         $cache = new A3C::Cache->new({ instance => '', dir => 'ldap' });  
 }  
46    
47  sub run {  sub run {
48          my $self = shift;          my $self = shift;
# Line 82  sub run { Line 78  sub run {
78                                  # let's create a new socket                                  # let's create a new socket
79                                  my $psock = $sock->accept;                                  my $psock = $sock->accept;
80                                  $sel->add($psock);                                  $sel->add($psock);
81                                  $Handlers{*$psock} = VLDAP::Server->new($psock);                                  $Handlers{*$psock} = LDAP::Virtual->new($psock);
82                          } else {                          } else {
83                                  my $result = $Handlers{*$fh}->handle;                                  my $result = $Handlers{*$fh}->handle;
84                                  if ($result) {                                  if ($result) {
# Line 98  sub run { Line 94  sub run {
94    
95  =head2 stop  =head2 stop
96    
97    my $stopped_pids = VLDAP::Server->stop;    my $stopped_pids = LDAP::Virtual->stop;
98    
99  =cut  =cut
100    
# Line 158  sub bind { Line 154  sub bind {
154          #$msg = $self->{upstream}->unbind;          #$msg = $self->{upstream}->unbind;
155          #warn "# unbind msg = ",dump( $msg );          #warn "# unbind msg = ",dump( $msg );
156    
157          $msg = $self->{upstream}->bind(          my $bind;
158                  dn => $req->{name},          $bind->{dn} = $req->{name} if $req->{name};
159                  password => $req->{authentication}->{simple}          $bind->{password} = $req->{authentication}->{simple} if $req->{authentication}->{simple};
160          );          warn "# bind ",dump( $bind );
161            $msg = $self->{upstream}->bind( %$bind );
162    
163          #warn "# bind msg = ",dump( $msg );          #warn "# bind msg = ",dump( $msg );
164          if ( $msg->code != LDAP_SUCCESS ) {          if ( $msg->code != LDAP_SUCCESS ) {
# Line 240  sub search { Line 237  sub search {
237    
238          warn "## entries = ",dump( @entries );          warn "## entries = ",dump( @entries );
239    
240          $self->cache->write_cache( \@entries, uri_escape( $filter ));          my $path = 'var/' . uri_escape( $filter ) . '.yml';
241            DumpFile( $path, \@entries );
242            warn "# created $path ", -s $path, " bytes";
243    
244          return RESULT_OK, @entries;          return RESULT_OK, @entries;
245  }  }

Legend:
Removed from v.2  
changed lines
  Added in v.31

  ViewVC Help
Powered by ViewVC 1.1.26