projects
/
virtual-ldap
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c91ceea
)
overlay yaml data over ldap entry
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 15 Mar 2009 19:48:21 +0000
(19:48 +0000)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 15 Mar 2009 19:48:21 +0000
(19:48 +0000)
bin/ldap-rewrite.pl
patch
|
blob
|
history
diff --git
a/bin/ldap-rewrite.pl
b/bin/ldap-rewrite.pl
index
ebf25b2
..
b3080f8
100755
(executable)
--- a/
bin/ldap-rewrite.pl
+++ b/
bin/ldap-rewrite.pl
@@
-15,6
+15,7
@@
use Convert::ASN1 qw(asn_read);
use Net::LDAP::ASN qw(LDAPRequest LDAPResponse);
our $VERSION = '0.2';
use fields qw(socket target);
use Net::LDAP::ASN qw(LDAPRequest LDAPResponse);
our $VERSION = '0.2';
use fields qw(socket target);
+use YAML qw/LoadFile/;
sub handle {
my $clientsocket=shift;
sub handle {
my $clientsocket=shift;
@@
-62,24
+63,41
@@
sub log_response {
Convert::ASN1::asn_hexdump(\*STDOUT,$pdu);
print "Response Perl:\n";
my $response = $LDAPResponse->decode($pdu);
Convert::ASN1::asn_hexdump(\*STDOUT,$pdu);
print "Response Perl:\n";
my $response = $LDAPResponse->decode($pdu);
- print dump($response);
if ( defined $response->{protocolOp}->{searchResEntry} ) {
my $uid = $response->{protocolOp}->{searchResEntry}->{objectName};
warn "## SEARCH $uid";
if ( defined $response->{protocolOp}->{searchResEntry} ) {
my $uid = $response->{protocolOp}->{searchResEntry}->{objectName};
warn "## SEARCH $uid";
+
+if(0) {
map {
if ( $_->{type} eq 'postalAddress' ) {
$_->{vals} = [ 'foobar' ];
}
} @{ $response->{protocolOp}->{searchResEntry}->{attributes} };
map {
if ( $_->{type} eq 'postalAddress' ) {
$_->{vals} = [ 'foobar' ];
}
} @{ $response->{protocolOp}->{searchResEntry}->{attributes} };
+}
+
+ my $path = "yaml/$uid.yaml";
+ if ( -e $path ) {
+ my $data = LoadFile($path);
+ warn "# yaml = ",dump($data);
+
+ foreach my $type ( keys %$data ) {
- push @{ $response->{protocolOp}->{searchResEntry}->{attributes} },
- { type => 'ffzg-datum_rodjenja', vals => [ '2009-01-01' ], }
- ;
+ my $vals = $data->{$type};
+ $vals =~ s{#\s*$}{};
+
+ my @vals = split(/\s*#\s*/, $vals);
+
+ push @{ $response->{protocolOp}->{searchResEntry}->{attributes} },
+ { type => "ffzg-$type", vals => [ @vals ] };
+ }
+ }
$pdu = $LDAPResponse->encode($response);
}
$pdu = $LDAPResponse->encode($response);
}
+ print dump($response);
+
return $pdu;
}
return $pdu;
}