[Ltb-users] file2ldif: modify replace and blank fields; multi-value attributes howto

Bryce Powell Bryce.Powell at TELUS.COM
Fri Oct 26 23:38:02 CEST 2012


Hi,

I have created the following mapping configuration:

# CSV delimiter (default is ",")
my $csv_delimiter = ";";

# Mapping configuration
my $map = {
    person_add => {
        dn => 'uid={1},ou={0},ou=Users,dc=private,dc=sdi',
        objectClass => [ 'Top', 'inetOrgPerson' ],
        uid => '{1}',
        cn => '{3} {4}',
        givenName => '{3}',
        sn => '{4}',
        mail => '{5}',
        preferredLanguage => '{7}',
        businessCategory => '{6}',
        employeeNumber => '{2}',
        l => '{8}',
        manager => 'uid={9},ou={0},ou=Users,dc=private,dc=sdi',    },
    },
    person_mod => {
        change_op => 'replace',
        dn => 'uid={1},ou={0},ou=Users,dc=private,dc=sdi',
        uid => '{1}',
        cn => '{3} {4}',
        givenName => '{3}',
        sn => '{4}',
        mail => '{5}',
        preferredLanguage => '{7}',
        businessCategory => '{6}',
        employeeNumber => '{2}',
        l => '{8}',
        manager => 'uid={9},ou={0},ou=Users,dc=private,dc=sdi',    },
};


1. How can I modify the file2ldif.pl script to only map attribute fields that have a value? E.g.

ou,employeeNumber,en,FirstName,LastName,mail,businessCategory,preferredLanguage,Province,managerUID
ACME,123456,,,,bryce_powell at telus.com,,,,

perl file2ldif.pl person_mod input.csv modify

Should generate the following LDIF:

dn: uid=123456,ou=ACME,ou=Users,dc=private,dc=sdi
changetype: modify
replace: mail
mail: bryce_powell at telus.com


2. Can the script handle multiple value attributes for add and modify (replace) operations? E.g. the businessCategory field has 'n' comma separated values. Where 'n' could be zero (i.e. blank field), or one or more values.

ou;employeeNumber;en;FirstName;LastName;mail;businessCategory;preferredLanguage;Province;managerUID
ACME;123456;123456;Bryce;Powell;bryce_powell at telus.com;value_1,value_2, ..., value_n;EN;BC;000001

perl file2ldif.pl person_add input.csv

Should generate the following LDIF (specifically, note the multiple businessCategory values):

dn: uid=123456,ou=ACME,ou=Users,dc=private,dc=sdi
changetype: add
employeeNumber: 123456
uid: 123456
cn: Bryce Powell
preferredLanguage: EN
objectClass: Top
objectClass: inetOrgPerson
manager: uid=000001,ou=ACME,ou=Users,dc=private,dc=sdi
l: BC
businessCategory: value_1
businessCategory: value_2
... etc.
businessCategory: value_n
sn: Powell
mail: bryce_powell at telus.com
givenName: Bryce

I've also tried using the following map, but it does not work as desired:
businessCategory => split(',', '{6}'),


Thanks,
Bryce


More information about the ltb-users mailing list