X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=bin%2Fldap-rewrite.pl;h=23e790bc68e6e9c5680166e6a0a8b3cf82a6b80a;hp=931eebd13d9c53d9b2d9c80a05137aa3af0d73a2;hb=af2a6460d3477b48c96ed89d4eb7805fba0663e9;hpb=9928416eb37d91738e1114165cf1a9c8071f1da8 diff --git a/bin/ldap-rewrite.pl b/bin/ldap-rewrite.pl index 931eebd..23e790b 100755 --- a/bin/ldap-rewrite.pl +++ b/bin/ldap-rewrite.pl @@ -84,13 +84,21 @@ sub log_response { my $uid = $response->{protocolOp}->{searchResEntry}->{objectName}; warn "## SEARCH $uid"; -if(0) { + my @attrs; + map { - if ( $_->{type} eq 'postalAddress' ) { - $_->{vals} = [ 'foobar' ]; + if ( $_->{type} eq 'hrEduPersonUniqueNumber' ) { + foreach my $val ( @{ $_->{vals} } ) { + next if $val !~ m{.+:.+}; + my ( $n, $v ) = split(/\s*:\s*/, $val ); + push @attrs, { type => $_->{type} . '_' . $n, vals => [ $v ] }; + } } } @{ $response->{protocolOp}->{searchResEntry}->{attributes} }; -} + + warn "# ++ attrs ",dump( @attrs ); + + push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, $_ foreach @attrs; my $path = $config->{yaml_dir} . "$uid.yaml"; if ( -e $path ) { @@ -100,12 +108,11 @@ if(0) { foreach my $type ( keys %$data ) { my $vals = $data->{$type}; - $vals =~ s{#\s*$}{}; - - my @vals = split(/\s*#\s*/, $vals); - push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, - { type => $config->{overlay_prefix} . $type, vals => [ @vals ] }; + push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, { + type => $config->{overlay_prefix} . $type, + vals => ref($vals) eq 'ARRAY' ? $vals : [ $vals ], + }; } } @@ -146,6 +153,8 @@ sub run_proxy { } +$ENV{LANG} = 'C'; # so we don't double-encode utf-8 if LANG is utf-8 + my $listenersock = IO::Socket::INET->new( Listen => 5, Proto => 'tcp',