How to setup a LDAP Server

Wed, Jul 1, 2009

Linux

Installation

  1. We need to install the ldap packages
    apt-get install slapd ldap-utils migrationtools
  2. Answer the questions and then use dpkg to reconfigure slapd for more options
    dpkg-reconfigure slapd

    Omit OpenLDAP server configuration? ... No
    DNS domain name: ... home.local
    Name of your organization: ... home
    Admin Password: some-really-strong-password
    Confirm Password: some-really-strong-password
    OK
    BDB
    Do you want your database to be removed when slapd is purged? ... No
    Move old database? ... Yes
    Allow LDAPv2 Protocol? ... No 
  3. Check that the ldap server is now running
    ldapsearch -x -b dc=home,dc=local

    If you get this error

    ldap_bind: Can't contact LDAP server (-1)

    Its likely the daemon isn't running so start it

    /etc/init.d/slapd start

Populating the Database

  • We can use migration tools to export all of our users and groups into the LDAP db switch into the migrations tools directory
    cd /usr/share/migrationtools/
  • Edit the migrations tools config file
    nano migrate_common.ph

    and replace the following

    DEFAULT_MAIL_DOMAIN = "home.local";
    DEFAULT_BASE = "dc=home,dc=local";
  • Export the users and groups
    ./migrate_group.pl /etc/group /tmp/group.ldif
    ./migrate_passwd.pl /etc/passwd /tmp/passwd.ldif 
  • Migrate tools doesn't create the group and people nodes therefore we need to create them open /tmp/nodes.ldif
    nano /tmp/nodes.ldif

    and paste in the following

    dn: ou=People, dc=home, dc=local
    ou: People
    objectclass: organizationalUnit
    
    dn: ou=Group, dc=home, dc=local
    ou: Group
    objectclass: organizationalUnit
  • Finally we need to import the entries into our LDAP database
    ldapadd -x -W -D "cn=admin,dc=home,dc=local" -f /tmp/nodes.ldif
    ldapadd -x -W -D "cn=admin,dc=home,dc=local" -f /tmp/group.ldif
    ldapadd -x -W -D "cn=admin,dc=home,dc=local" -f /tmp/passwd.ldif 
  • That is your LDAP server setup In this tutorial it will show you how to configure your LDAP Clients

    , , , , , , ,

    This post was written by:

    Duffy - who has written 48 posts on Tuts4Tech.

    I am the owner of this website, please feel free to ask me any questions you have

    Contact the author

    This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

    Leave a Reply