Wednesday, 19 March 2014

Basic LDAP server configuration in Linux

Packages requires for openldap:
    compat-openldap.i386 0:2.1.30-6.4E
    openldap-clients.i386 0:2.2.13-6.4E
    openldap-devel.i386 0:2.2.13-6.4E
    openldap-servers.i386 0:2.2.13-6.4E
    openldap-servers-sql.i386 0:2.2.13-6.4E

Step 1: Install openldap
#yum install *openldap* -y

Step 2: Start the service
# chkconfig --levels 235 ldap on
# service ldap start 


Step 3: Create LDAP root user password
# slappasswd
    New password:
    Re-enter new password:
    {SSHA}aWB1VzqDXZLf6F4lwvwNvApBQ89G/DltW

Step 4: Configure the file  /etc/openldap/slapd.conf for the root password
# vi /etc/openldap/slapd.conf
    #68 database        bdb
    #69 suffix          "dc=adminmart,dc=com"
    #70 rootdn          "cn=Manager,dc=adminmart,dc=com"
    #71 rootpw          {SSHA}aWB1VzqDXZLf6F4lwvwNvApBQ89G/DltW

save & exit
#service ldap restart

Step 5: Create test users
# useradd ldapuser1
# passwd ldapuser1
    Changing password for user ldapuser1.
    New UNIX password:
    Retype new UNIX password:
    passwd: all authentication tokens updated successfully.
# useradd ldapuser2
# passwd ldapusert2
    Changing password for user ldapuser2.
    New UNIX password:
    Retype new UNIX password:
    passwd: all authentication tokens updated successfully.
 
Note: Repeat if you need some more ldap users.

Step 6: Migrate local users to LDAP
# grep root /etc/passwd > /etc/openldap/passwd.root
# grep ldapuser1 /etc/passwd > /etc/openldap/passwd. ldapuser 1
# grep ldapuser2 /etc/passwd > /etc/openldap/passwd.ldapuser2
 Note: Repeat the same for the rest of users

Step 7: Update default settings on file /usr/share/openldap/migration/migrate_common.ph
    #71 $DEFAULT_MAIL_DOMAIN = "adminmart.com";
    #74 $DEFAULT_BASE = "dc=adminmart,dc=com";

Step 8: Convert passwd.file to ldif file 
# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd.root /etc/openldap/root.ldif
# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd. ldapuser 1 /etc/openldap/ ldapuser 1.ldif
# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd. ldapuser 2 /etc/openldap/ ldapuser 2.ldif
Note: Repeat the same for other users

Step 9: Update root.ldif file for the "Manager" of LDAP Server 
# vi /etc/openldap/root.ldif
    #1 dn: uid=root,ou=People,dc=adminmart,dc=com
    #2 uid: root
    #3 cn: Manager
    #4 objectClass: account
save & exit

Step 10: Create a domain ldif file (/etc/openldap/adminmart.com.ldif)
# cat /etc/openldap/adminmart.com.ldif
    dn: dc=adminmart,dc=com
    dc: adminmart
    description: LDAP Admin
    objectClass: dcObject
    objectClass: organizationalUnit
    ou: rootobject
    dn: ou=People, dc=adminmart,dc=com
    ou: People
    description: Users of adminmart
    objectClass: organizationalUnit

Step 11: Import all users in to the LDAP
Add the Domain ldif file 
# ldapadd -x -D "cn=Manager,dc=adminmart,dc=com" -W -f  /etc/openldap/adminmart.com.ldif
    Enter LDAP Password:
    adding new entry "dc=adminmart,dc=com"
    adding new entry "ou=People, dc=adminmart,dc=com"
Add the users:
# ldapadd -x -D "cn=Manager,dc=adminmart,dc=com" -W -f  /etc/openldap/root.ldif
    Enter LDAP Password:
    adding new entry "uid=root,ou=People,dc=adminmart,dc=com"
    adding new entry "uid=operator,ou=People,dc=adminmart,dc=com"

# ldapadd -x -D "cn=Manager,dc=adminmart,dc=com" -W -f  /etc/openldap/ ldapuser 1.ldif
    Enter LDAP Password:
    adding new entry "uid= ldapuser1,ou=People,dc=adminmart,dc=com"

# ldapadd -x -D "cn=Manager,dc=adminmart,dc=com" -W -f  /etc/openldap/ ldapuser 2.ldif
    Enter LDAP Password:
    adding new entry "uid= ldapuser2,ou=People,dc=adminmart,dc=com"

 Note: Repeat the same for the rest of users

Step 12: Apply Changes 
# service ldap restart 

Step 13: verify LDAP Server
Shows all the ldapuser information:
# ldapsearch -x -b 'dc=adminmart,dc=com' '(objectclass=*)' 

 

1 comment:

  1. When I thought about the way things have been recently, i owe my thanks to God for letting me find this amazing personality, i mailed Mr. alex roughly 2 months now, I was actually very uncertain about investing, very scared because i was also low on cash.I gave it my all, my first investment of $2,000 two weeks ago brought me $ 29,230 last week, and what intrigues me the most is the way him handles he partners, i recommend him too to my friend jeff, after trading with him, his testimonies have let me come here to attest for him. We are happy to meet a professional in you. I am proud to recommend him to any person who has a passion for trading, meet a good mentor and get good fortunes.Contact this veteran at: totalinvestmentcompany@gmail.com

    ReplyDelete