X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=lib%2FLDAP%2FVirtual.pm;h=4ee090e3f76fcd8c08b75160afcb51c187a714cd;hp=3b17bd4f65ab7918eafcffde70b35be1cfb7d9c9;hb=8d4f1b042a6168d3423dc2edc7ea79d2cee7d4fb;hpb=fddf50f78d99fcc269188fcdc7eeab73d2824421 diff --git a/lib/LDAP/Virtual.pm b/lib/LDAP/Virtual.pm index 3b17bd4..4ee090e 100644 --- a/lib/LDAP/Virtual.pm +++ b/lib/LDAP/Virtual.pm @@ -20,6 +20,8 @@ use URI::Escape; # uri_escape use IO::Socket::INET; use IO::Select; +use YAML qw/DumpFile/; + use Data::Dump qw/dump/; =head1 NAME @@ -41,12 +43,6 @@ Provide LDAP server functionality somewhat similar to C =cut our $pids; -our $cache; - -sub cache { - return $cache if $cache; - $cache = new A3C::Cache->new({ instance => '', dir => 'ldap' }); -} sub run { my $self = shift; @@ -160,6 +156,14 @@ sub bind { my $bind; $bind->{dn} = $req->{name} if $req->{name}; + + if ( $bind->{dn} =~ m{@} ) { + + $bind->{dn} =~ s/[@\.]/,dc=/g; + $bind->{dn} =~ s/^/uid=/; + + } + $bind->{password} = $req->{authentication}->{simple} if $req->{authentication}->{simple}; warn "# bind ",dump( $bind ); $msg = $self->{upstream}->bind( %$bind ); @@ -241,7 +245,9 @@ sub search { warn "## entries = ",dump( @entries ); - $self->cache->write_cache( \@entries, uri_escape( $filter )); + my $path = 'var/' . uri_escape( $filter ) . '.yml'; + DumpFile( $path, \@entries ); + warn "# created $path ", -s $path, " bytes"; return RESULT_OK, @entries; }