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; |
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 |
|
|