Ldapimport

From Kolab wiki

Jump to: navigation, search


Contents

Manual import

Import Addresses or Users

With ldapadd or slapadd you are able to very easily add large amounts of address information or kolab users. This example sticks with the somehow not so popular ldapadd.

ldapsearch

List the content of your ldap - If you've allready created a contact, it will look a little like that (output is edited):

root@server:/ # ldapsearch -x
# extended LDIF
#
# LDAPv3
# base <> with scope sub
# filter: (objectclass=*)
# requesting: ALL
#
#
# cabag.ch
dn: dc=cabag,dc=ch
dc: cabag
objectClass: top
objectClass: domain
#
# external, cabag.ch
dn: cn=external,dc=cabag,dc=ch
cn: external
objectClass: top
objectClass: kolabNamedObject
#
# testvorname testname, external, cabag.ch
dn: cn=testvorname testname,cn=external,dc=cabag,dc=ch
objectClass: top
objectClass: inetOrgPerson
objectClass: kolabInetOrgPerson
sn: testname
cn: testvorname testname
givenName: testvorname
title: testtitel
mail: test@test.com
o: testorg
ou: testorgunit
roomNumber: zimmer 123
street: teststrasse 123
postOfficeBox: po-123
postalCode: 1234
l: teststadt
c: testland
telephoneNumber: 123
facsimileTelephoneNumber: 123
alias: testalias@test.com
alias: testalias2@test.com

So far so good... The above example shows test@test.com's contact information. This contact was created using kolab's webinterface - all fields offerd by addr.php?action=create populated.

ldif

Grab your favorite text editor and create this.ldif - which contains something like the example showed below. Remember to alter dn: cn=Hans Maulwurf,dc=yourdomain so it fits your setup.

# Hans Maulwurf, external, cabag.ch
dn: cn=Hans Maulwurf,cn=external,dc=cabag,dc=ch
objectClass: top
objectClass: inetOrgPerson
objectClass: kolabInetOrgPerson
sn: Maulwurf
cn: Hans Maulwurf
givenName: Hans
title: Master of the known Universe
mail: hans@maulwurf.tld
o: supercorp
ou: specialunit
roomNumber: 8023
street: paperstreet 42
postOfficeBox: 65535
postalCode: 1234
l: supercity
c: wonderland
telephoneNumber: +4 555 999 9999
facsimileTelephoneNumber: +4 555 888 8888

ldapadd

root@server:/ # ldapadd -D cn=manager,cn=internal,dc=cabag,dc=ch -x -w <your kolab manager password> -f this.ldif
adding new entry "cn=Hans Maulwurf,cn=external,dc=cabag,dc=ch"

If the .ldif contains the attribute uid:, it will be a kolab user. In this case, the .ldif should also contain the attribute kolabInvitationPolicy:

Of course the ldif may contain more than just one entry - but take care of the seperation (two newlines should do well).

Whenever you add e-mail users the kolab2-system should detect the change and add the corresponding mailboxes automatically. Should you come across a situation where this is not the case, please file a bug report for this and try to provide a way to re-create that situation!

Setting LDAP password

Setting the password via LDAP is a little tricky but not a problem: LDAP at all and also the Kolab2-System supports the usage of SHA for password hashing. Exactly the plain password string is first SHA1-cyphered and then MIME-encoded (base_64). You can see it when looking around in the PHP-files of the Kolab2-Management-Pages in /kolab/var/kolab/www.

In PERL the following codelines convert a plain password into a correct Kolab2-LDAP-password:

 #! /usr/bin/perl
 #
 # This small script generates an SHA1 hash of 'secret' for use
 # as a userPassword or rootpw value.
 #
 use Digest::SHA1;
 use MIME::Base64;
 $ctx = Digest::SHA1->new;
 $ctx->add('secret');
 $hashedPasswd = '{SHA}' . encode_base64($ctx->digest,);
 print 'userPassword: ' .  $hashedPasswd . "\n";

The LDAP-Attribute for the password is "userPassword" (in Kolab2 too).

Automatic import

Check out Csvtoldap.pl for automated Account conversion from .CSV-files.

Personal tools