Linux Miscellaneous (11): Building an LDAP server

Source: Internet
Author: User
1 LDAP introduction today we will introduce the establishment of the LDAP server and access to the client, but the main problem lies in the former. First, we need to know what L 1. Introduction to LDAP

Today we will introduce how to build an LDAP server and access the client, but the main problem is the former. First, we need to know what LDAP is.

In daily conversations, you may hear some people say, "Do we need to store those things in LDAP? ", Or" retrieve the data from the LDAP database! ", Or" how do we integrate LDAP with relational databases? ". Strictly speaking, LDAP is not a database, but a protocol for accessing information stored in the Information Directory (that is, the LDAP directory. The more accurate and formal statement should be like this: "By using LDAP, you can read (or store) data in the correct location of the Information Directory ".

Advantages of LDAP:

(1) cross-platform and standard protocols
(2) the installation is simple, easy to maintain, and easier to maintain than relational databases.

What LDAP stores and shares is generally not changed frequently. for example, we need to store the user passwords of employees on the LDAP server, in this way, you can use the specified user to log on to any server that can access the LDAP server, instead of logging on to the local user of each server as before. Is it more convenient. Now let's start to build an LDAP server.

2. build an LDAP server

(1) preparations

We need two hosts, one being a real machine and the other being a virtual machine, as long as they can communicate in the same network segment.
The versions of both hosts are redhat6.4 (other versions may be different from this)

(2) Start configuration

1. The first is the server. we need to install the LDAP server first:


2. copy the template of the configuration file to the configuration Directory:


3. delete unused configuration files lapd. conf.


4. modify the configuration file permissions and users:


5. edit the configuration file and modify the following:
(1) comment out the encrypted lines starting with TLS;

(2) comment out this part:

(3) make the following changes:

Note that rootpw must start with this line, otherwise it will not take effect !!!

(4) restart the sldap service:


6. although the service has been configured, we have not created any users to share. below we will create 100 users using scripts:


Execute the user creation process, but because it is a shell script, the execution process will be slow, patience, etc. you can view the creation progress in the/etc/passwd file.

We can see that 100 new users have been successfully created:


However, there is a problem that the writing formats of these users cannot be directly imported to the LDAP server. Therefore, we must use a format conversion tool to convert the format:
Migrationtools is a format conversion tool. we will install it first:


After the installation, we jump to its directory and find that there are many executable scripts used to constrain the format:


Modify the following items in migrate_common.ph:


Set the basic import model: generate base. ldif and modify base. ldif:

Because we only set its users and groups, all are left with only these two parts, and all others are deleted:

Transfer base. ldif to the/ldapuser Directory:


The following two operations are the most critical. we need to extract the shared user and group information from passwd and group:


Then convert the user and group information into a format that can be put on the LDAP server:
Conversion User:

Conversion Group:


Import the basic template first, and then import the user and group information:





Restart the slapd service and refresh the firewall.


Now, the configuration of the LDAP server without a security key is complete. We use the server of another machine to access it and switch users:


IP address written to the server:


Okay !! The most exciting time is now. we switch the user to myldapuser1, which is unavailable on the client but can be logged on now.


This indicates that users on the server are successfully shared and can be accessed by other hosts. The biggest advantage is that we can only change the user and group information of the server to complete the impact on other clients. Very practical and convenient. This is only a feature of the LDAP service. In the future, we will have a better understanding.

Note: This service is configured in the RHCA stage. if you feel it is difficult for the first time, configure the service several times and summarize it into a document. your understanding of LDAP will be enhanced.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.