projects
/
virtual-ldap
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
support ARRAY values from yaml file
[virtual-ldap]
/
bin
/
ldap-rewrite.pl
diff --git
a/bin/ldap-rewrite.pl
b/bin/ldap-rewrite.pl
index
931eebd
..
6d2fa2d
100755
(executable)
--- 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";
my $uid = $response->{protocolOp}->{searchResEntry}->{objectName};
warn "## SEARCH $uid";
-if(0) {
+ my @attrs;
+
map {
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} };
}
} @{ $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 ) {
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};
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 ],
+ };
}
}
}
}