ldap這種原始的服務器搭建起來比較復雜,同時它也是CE必考的(客戶端的搭建)。
1、安裝openldap-servers軟件包

2、查看ldap模板文件的存放位置:

3、拷貝ldap模板文件到配置文件目錄並修改文件名為slapd.conf。


4、刪除/etc/openldap目錄下原有的文件,保留下這幾個文件,注意:以前學時是要刪除schema文件,直留下三個,但是我測試時如果刪除schema服務將失敗。

5、修改slapd.conf文件的權限:


6、修改sldap.conf配置文件:如下:(主要配好紅色的就ok,沒有的都是被注釋掉的)
復制代碼代碼如下:
include /etc/openldap/schema/corba.schema
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/duaconf.schema
include /etc/openldap/schema/dyngroup.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/java.schema
include /etc/openldap/schema/misc.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/openldap.schema
include /etc/openldap/schema/ppolicy.schema
include /etc/openldap/schema/collective.schema
allow bind_v2
pidfile /var/run/openldap/slapd.pid argsfile /var/run/openldap/slapd.args
database bdb suffix "dc=example,dc=com" checkpoint 1024 15 rootdn
"cn=Manager,dc=example,dc=com"
rootpw redhat
directory /var/lib/ldap
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
database monitor
access to * by dn.exact="cn=Manager,dc=example,dc=com" read by * none
7、重啟動ldap服務器:

8、創建ldap用戶目錄:

9、編輯一個自動創建ldap用戶的腳本:

10 、執行此腳本添加用戶:

11、把ldap用戶,組分別導出來,到一個文件中:(例子只做了組)用戶在、/etc/passwd下

12、安裝軟件包:

13、去它的目錄下編譯ldap用戶組文件:

14、修改migrate_common.ph文件:

15、執行./migrate_base.pl文件,並導出到一個目錄下邊,進行進行修改,只留下最基本的三個配置:

16,、分別使用./migrate_passwd.pl ./migrate_group.pl編譯我們已經導出的ldap用戶和組文件: /mnt/user /mnt/group分別是從/etc/passwd /etc/group 導出的ldap用戶和組文件
/date/user.ldif /date/group.ldif 是編譯後生成的文件要以ldif結尾

17、看下/date下我們編譯好的幾個文件:

18、添加ldap用戶和組:

首先提示輸入密碼,其次添加成功。

還有個用戶,必須首先執行base.ldif文件,它是最基本的配置。
