From ebe45217c311d5db516c8b39e36985c216ee7909 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 21 Apr 2015 16:47:41 +0200 Subject: [PATCH] [DO NOT PUSH] Bug 8993: Sample LDAP transformation module --- C4/LDAPTransform/RepeatableValues.pm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 C4/LDAPTransform/RepeatableValues.pm diff --git a/C4/LDAPTransform/RepeatableValues.pm b/C4/LDAPTransform/RepeatableValues.pm new file mode 100644 index 0000000..0c65156 --- /dev/null +++ b/C4/LDAPTransform/RepeatableValues.pm @@ -0,0 +1,29 @@ +package C4::LDAPTransform::RepeatableValues; + +use warnings; +use strict; + +my $mapping = { qw/ + givenName firstname + sn surname + uid userid + mail email + categorycode categorycode + branchcode branchcode +/ }; + +sub get_borrower { + my $ldap_entry = shift; + $ldap_entry->isa('Net::LDAP::Entry') or die "argument to transform get_borrower is not Net::LDAP::Entry"; + + my $user = { column => {} }; + + while (my ($from, $to) = each %$mapping) { + my @vals = $ldap_entry->get_value( $from ); + $user->{column}->{$to} = $vals[0]; + } + + return $user; +} + +1; -- 1.9.1