2012/10/26 Bryce Powell <[email protected]>:
> 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,,,,[email protected],,,,
>
> 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: [email protected]
>


Empty values should be automatically removed, by this pice of code in
the script :

        # Remove empty values
        while ( my ( $key, $value ) = each(%localmap) ) {
            delete $localmap{$key} if ( $value eq "" );
        }



>
> 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;[email protected];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: [email protected]
> givenName: Bryce
>
> I've also tried using the following map, but it does not work as desired:
> businessCategory => split(',', '{6}'),

This is not managed yet, you have to adapt the code in this part :

            # Write every column as attribute
            my $entry = Net::LDAP::Entry->new('o=fakedn');
            for my $i ( 0 .. $#columns ) {
                $entry->add( $i => $columns[$i] );
            }
            $inldif->write_entry($entry);


Clément.
_______________________________________________
ltb-users mailing list
[email protected]
http://lists.ltb-project.org/listinfo/ltb-users

Reply via email to