rewrite DN from login@domain.com into uid=login,dc=domain,dc=com
[virtual-ldap] / lib / LDAP / Virtual.pm
index 10893bc..4ee090e 100644 (file)
@@ -43,11 +43,6 @@ Provide LDAP server functionality somewhat similar to C<slapo-rwm>
 =cut
 
 our $pids;
-our $cache;
-
-sub cache {
-       return $cache;
-}
 
 sub run {
        my $self = shift;
@@ -161,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 );
@@ -242,10 +245,8 @@ sub search {
 
        warn "## entries = ",dump( @entries );
 
-#      $self->cache->write_cache( \@entries, uri_escape( $filter ));
-
-       my $path = uri_escape( $filter );
-       DumpFile( "var/${path}.yml", \@entries );
+       my $path = 'var/' . uri_escape( $filter ) . '.yml';
+       DumpFile( $path, \@entries );
        warn "# created $path ", -s $path, " bytes";
 
        return RESULT_OK, @entries;