Revision 84

Date:
2010/03/01 18:57:30
Author:
dpavlin
Revision Log:
reformat attributes with date in name and format yyyymmdd into iso yyyy-mm-dd format
for easier import into databases
Files:

Legend:

 
Added
 
Removed
 
Modified
  • bin/ldap-rewrite.pl

     
    136 136
    137 137 my @attrs;
    138 138
    139 map {
    140 if ( $_->{type} eq 'hrEduPersonUniqueNumber' ) {
    141 foreach my $val ( @{ $_->{vals} } ) {
    139 foreach my $attr ( @{ $response->{protocolOp}->{searchResEntry}->{attributes} } ) {
    140 if ( $attr->{type} =~ m/date/i ) {
    141 foreach my $i ( 0 .. $#{ $attr->{vals} } ) {
    142 $attr->{vals}->[$i] = "$1-$2-$3" if $attr->{vals}->[$i] =~ m/^([12]\d\d\d)([01]\d+)([123]\d+)$/;
    143 }
    144 } elsif ( $attr->{type} eq 'hrEduPersonUniqueNumber' ) {
    145 foreach my $val ( @{ $attr->{vals} } ) {
    142 146 next if $val !~ m{.+:.+};
    143 147 my ( $n, $v ) = split(/\s*:\s*/, $val );
    144 148 push @attrs, { type => $_->{type} . '_' . $n, vals => [ $v ] };
    145 149 }
    146 150 }
    147 } @{ $response->{protocolOp}->{searchResEntry}->{attributes} };
    151 }
    148 152
    149 153 warn "# ++ attrs ",dump( @attrs );
    150 154