open LDAP 在線安裝和配置-基於centos 7


安裝openldap

注意:centos7中用yum安裝的已是最新的openldap2.4的版本,默認配置方式是slapd(8) ,沒有slapd.conf文件,若采取slapd.conf(5)方式需要新建該文件。

1、檢查是否已經安裝:rpm -qa openldap-servers

2、需要安裝的包

  • 必須
    • openldap-servers
    • openldap-clients(包含LDAP增、刪、改、查等命令)
  • 可選
    • openldap-devel

3、安裝:yum -y install [包名]

4、啟停:systemctl start/stop/status slapd(利用slapd.ldif更改配置后將不再起作用),可以用slapd命令

5、驗證:ldapsearch -x -b ' ' -s base '(objectclass=*)',ldapserach --help可查看幫助

6、目錄位置(默認安裝)

  • 數據保存:/var/lib/ldap
  • 配置文件:/etc/openldap/
  • 守護進程:/usr/sbin/slapd

7、生成密文密碼:slappaswd

請復制該密文,配置中使用。當然也可忽略此步。


配置openLDAP

兩個主要配置目錄

  • 默認配置文件所在目錄:/usr/share/openldap-servers/
  • 配置文件目錄:/etc/openldap/,其中,主要配置文件在slapd.d目錄下

方式一

  • 法1:采用slapd(8)方式,直接編輯/etc/openldap/slapd.d/olcDatabase={2}hdb.ldif(官方未提及,網友倒是樂此不疲),此處亦不作詳解。
  • 法2:通過ldif文件生成,詳情參考:http://www.openldap.org/doc/admin24/slapdconf2.html
    1. 編輯slapd.ldif
    2. 利用命令:slapadd -v -F /etc/openldap/slapd.d/ -l slapd.ldif -n 0生成配置
    3. 啟動:slapd -F slapd.d

方式二

采用slapd.conf(5)方式

1、新建slapd.conf文件,以下示例是一份最簡單的配置,詳情參考:http://www.openldap.org/doc/admin24/slapdconfig.html

 1 # Schema and objectClass definitions
 2 include         /etc/openldap/schema/core.schema
 3 include         /etc/openldap/schema/cosine.schema
 4 include         /etc/openldap/schema/nis.schema
 5 include         /etc/openldap/schema/inetorgperson.schema
 6 include         /etc/openldap/schema/openldap.schema
 7 
 8 # Where the pid file is put. The init.d script
 9 # will not stop the server if you change this.
10 pidfile         /var/run/openldap/slapd.pid
11 
12 # List of arguments that were passed to the server
13 argsfile        /var/run/openldap/slapd.args
14 
15 # Specific Directives for database #1, of type @BACKEND@:
16 # Database specific directives apply to this databasse until another
17 # 'database' directive occurs
18 database        mdb
19 
20 # The base of your directory in database #1
21 suffix          "dc=test,dc=com"
22 
23 # rootdn directive for specifying a superuser on the database. This is needed
24 # for syncrepl.
25 rootdn          "cn=root,dc=test,dc=com"
26 
27 #此處便是前面的slappasswd生成的,當然你也可以用明文
28 rootpw          {SSHA}kQSPnfgc8Va+IDh2saHfZ1F7rzN8mRvn
29 
30 # Where the database file are physically stored for database #1
31 directory       "/var/lib/ldap"
32 
33 # Indexing options for database #1
34 index            objectClass eq
View Code

2、檢查配置:slaptest -u -f slapd.cong,若有錯誤,請根據提示更改錯誤

3、啟動:slap -f slapd.conf(此處需要在slapd.conf目錄下,否則需要加入slapd.conf的絕對位置)

4、初始化根entry

  • 新建文件initRootEntry.ldif
    1 dn: dc=test,dc=com
    2 objectClass: dcObject
    3 objectClass: organization
    4 o: this is test
    5 dc: test
    View Code
  • 利用命令:ldapadd -x -D "cn=root,dc=test,dc=com" -W -f initRootEntry.ldif導入根entry信息

5、大功告成,繼續深究

一些LDAP服務的管理軟件


 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM