X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=bin%2Fldap-rewrite.pl;h=f7be5e34b88412498d721f90ebccab180cd32e9f;hp=5994286521835c86b4ddb9790f5ce42d950fa9a2;hb=ba9db0ee32da23d842c080b6202a9f26f4cd7cfa;hpb=d76d841dcbea1c0dfa919236720026405d1ddba6 diff --git a/bin/ldap-rewrite.pl b/bin/ldap-rewrite.pl index 5994286..f7be5e3 100755 --- a/bin/ldap-rewrite.pl +++ b/bin/ldap-rewrite.pl @@ -136,15 +136,19 @@ sub log_response { my @attrs; - map { - if ( $_->{type} eq 'hrEduPersonUniqueNumber' ) { - foreach my $val ( @{ $_->{vals} } ) { + foreach my $attr ( @{ $response->{protocolOp}->{searchResEntry}->{attributes} } ) { + if ( $attr->{type} =~ m/date/i ) { + foreach my $i ( 0 .. $#{ $attr->{vals} } ) { + $attr->{vals}->[$i] = "$1-$2-$3" if $attr->{vals}->[$i] =~ m/^([12]\d\d\d)([01]\d+)([0123]\d+)$/; + } + } elsif ( $attr->{type} eq 'hrEduPersonUniqueNumber' ) { + foreach my $val ( @{ $attr->{vals} } ) { next if $val !~ m{.+:.+}; my ( $n, $v ) = split(/\s*:\s*/, $val ); - push @attrs, { type => $_->{type} . '_' . $n, vals => [ $v ] }; + push @attrs, { type => $attr->{type} . '_' . $n, vals => [ $v ] }; } } - } @{ $response->{protocolOp}->{searchResEntry}->{attributes} }; + } warn "# ++ attrs ",dump( @attrs );