read additional yaml files from yaml/attribute/value.yaml
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 13 Jul 2010 14:50:58 +0000 (14:50 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 13 Jul 2010 14:50:58 +0000 (14:50 +0000)
bin/ldap-rewrite.pl

index f7be5e3..b35822e 100755 (executable)
@@ -154,10 +154,21 @@ sub log_response {
 
                push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, $_ foreach @attrs;
 
 
                push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, $_ foreach @attrs;
 
-               my $path = $config->{yaml_dir} . "$uid.yaml";
-               if ( -e $path ) {
-                       my $data = LoadFile($path);
-                       warn "# yaml = ",dump($data);
+               my @additional_yamls = ( $uid );
+               foreach my $attr ( @{ $response->{protocolOp}->{searchResEntry}->{attributes} } ) {
+                       foreach my $v ( @{ $attr->{vals} } ) {
+                               push @additional_yamls, $attr->{type} . '/' . $v;
+                       }
+               }
+
+               #warn "# additional_yamls ",dump( @additional_yamls );
+
+               foreach my $path ( @additional_yamls ) {
+                       my $full_path = $config->{yaml_dir} . '/' . $path . '.yaml';
+                       next unless -e $full_path;
+
+                       my $data = LoadFile( $full_path );
+                       warn "# $full_path yaml = ",dump($data);
 
                        foreach my $type ( keys %$data ) {
 
 
                        foreach my $type ( keys %$data ) {