/[virtual-ldap]/bin/ldap-rewrite.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/ldap-rewrite.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8 by dpavlin, Sun Mar 15 18:53:37 2009 UTC revision 10 by dpavlin, Sun Mar 15 19:48:21 2009 UTC
# Line 15  use Convert::ASN1 qw(asn_read); Line 15  use Convert::ASN1 qw(asn_read);
15  use Net::LDAP::ASN qw(LDAPRequest LDAPResponse);  use Net::LDAP::ASN qw(LDAPRequest LDAPResponse);
16  our $VERSION = '0.2';  our $VERSION = '0.2';
17  use fields qw(socket target);  use fields qw(socket target);
18    use YAML qw/LoadFile/;
19    
20  sub handle {  sub handle {
21          my $clientsocket=shift;          my $clientsocket=shift;
# Line 62  sub log_response { Line 63  sub log_response {
63          Convert::ASN1::asn_hexdump(\*STDOUT,$pdu);          Convert::ASN1::asn_hexdump(\*STDOUT,$pdu);
64          print "Response Perl:\n";          print "Response Perl:\n";
65          my $response = $LDAPResponse->decode($pdu);          my $response = $LDAPResponse->decode($pdu);
         print dump($response);  
66    
67          if ( defined $response->{protocolOp}->{searchResEntry} ) {          if ( defined $response->{protocolOp}->{searchResEntry} ) {
68                  my $uid = $response->{protocolOp}->{searchResEntry}->{objectName};                  my $uid = $response->{protocolOp}->{searchResEntry}->{objectName};
69                  warn "## SEARCH $uid";                  warn "## SEARCH $uid";
70    
71    if(0) {
72                  map {                  map {
73                          if ( $_->{type} eq 'postalAddress' ) {                          if ( $_->{type} eq 'postalAddress' ) {
74                                  $_->{vals} = [ 'foobar' ];                                  $_->{vals} = [ 'foobar' ];
75                          }                          }
76                  } @{ $response->{protocolOp}->{searchResEntry}->{attributes} };                  } @{ $response->{protocolOp}->{searchResEntry}->{attributes} };
77    }
78    
79                  push @{ $response->{protocolOp}->{searchResEntry}->{attributes} },                  my $path = "yaml/$uid.yaml";
80                          { type => 'ffzg-datum_rodjenja', vals => [ '2009-01-01' ], }                  if ( -e $path ) {
81                  ;                          my $data = LoadFile($path);
82                            warn "# yaml = ",dump($data);
83    
84                            foreach my $type ( keys %$data ) {
85    
86                                    my $vals = $data->{$type};
87                                    $vals =~ s{#\s*$}{};
88                                    
89                                    my @vals = split(/\s*#\s*/, $vals);
90    
91                                    push @{ $response->{protocolOp}->{searchResEntry}->{attributes} },
92                                            { type => "ffzg-$type", vals => [ @vals ] };
93                            }
94                    }
95    
96                  $pdu = $LDAPResponse->encode($response);                  $pdu = $LDAPResponse->encode($response);
97          }          }
98    
99            print dump($response);
100    
101          return $pdu;          return $pdu;
102  }  }
103    

Legend:
Removed from v.8  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26