split hrEduPersonUniqueNumber into separate attributes
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 16 Mar 2009 09:46:47 +0000 (09:46 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 16 Mar 2009 09:46:47 +0000 (09:46 +0000)
based on prefix: within field

bin/ldap-rewrite.pl

index 931eebd..d3d8da0 100755 (executable)
@@ -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 ) {