安裝 LDAP 的需求是要給未來 E-mail、Radius、Proxy及無線網路用的 ^^
1. 安裝 LDAP Server
# cd /usr/ports/net/openldap23-server
# make install clean
2. 安裝好之後,需先設定 LDAP 管理者 root 的密碼,並記下來等會兒設定至 slapd.conf
# slappasswd ( 就會產生出利用 SSHA 編碼後的密碼 )
3. 修改 slapd.conf,此檔案為 LDAP Server 主要 Config 檔,以下是我的設定檔
# 載入想要用的 Schema
include /usr/local/etc/openldap/schema/core.schema
include /usr/local/etc/openldap/schema/corba.schema
include /usr/local/etc/openldap/schema/cosine.schema
include /usr/local/etc/openldap/schema/misc.schema
include /usr/local/etc/openldap/schema/inetorgperson.schema
include /usr/local/etc/openldap/schema/openldap.schema
include /usr/local/etc/openldap/schema/nis.schema
# Define global ACLs to disable default read access.
# 針對密碼的部份,可讓使用者自己修改、讓任何人驗證、讓管理者修改,其餘都禁止
access to attrs=userPassword
by self write
by anonymous auth
by dn.base="cn=root,dc=ldap,dc=bojack,dc=com,dc=tw" write
by * none
# 針對所有資訊,可讓使用者自行修改,讓匿名者可讀取,讓管理者可以寫
access to *
by self write
by users read
by anonymous peername.IP=127.0.0.1 read
by anonymous peername.IP=10.1.17.0%255.255.255.0 read
by dn.base="cn=root,dc=ldap,dc=bojack,dc=com,dc=tw" write
by * none
# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral ldap://root.openldap.org
loglevel 296
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
# Load dynamic backend modules:
modulepath /usr/local/libexec/openldap
moduleload back_bdb
#####################
# BDB database definitions
#####################
database bdb
suffix "dc=ldap,dc=bojack,dc=com,dc=tw"
rootdn "cn=root,dc=ldap,dc=bojack,dc=com,dc=tw"
# Cleartext passwords, especially for the rootdn, should
# be avoid. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
#rootpw secret
rootpw {SSHA}fA6jKolq3R0EpGkvJiNmgigoMRvP/RCS
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory /var/db/openldap-data
# Indices to maintain
index objectClass eq
4. 因為在 slapd.conf 裡有設置 loglevel 參數,因此配合修改 syslog.conf
# vi /etc/syslog.conf
local4.* /var/log/ldap.log
# touch /var/log/ldap.log
# /etc/rc.d/syslogd restart
5. 啟動 LDAP Service
# vi /etc/rc.conf
slapd_enable="YES"
slapd_flags='-h "ldapi://%2fvar%2frun%2fopenldap%2fldapi/ ldap://0.0.0.0/"'
slapd_sockets="/var/run/openldap/ldapi"
# /usr/local/etc/rc.d/slapd start
6. 匯入 BaseDN、RootDN 和職員OU的 ldif 檔
這是我的 ldif 檔
# KNU LDAP Base DN
dn: dc=ldap,dc=bojack,dc=com,dc=tw
objectClass: dcObject
objectClass: organization
dc: ldap
o: BOJACK-LDAP
# Magager ldap.bojack.com.tw Root DN
dn: cn=root,dc=ldap,dc=bojack,dc=com,dc=tw
objectClass: organizationalRole
cn: root
dn: ou=employee,dc=ldap,dc=bojack,dc=com,dc=tw
ou: employee
objectClass: organizationalUnit
description: employee
# ldapadd -x -D "cn=root,dc=ldap,dc=bojack,dc=com,dc=tw" -W -f base.ldif
7. 驗證一下 ldapsearch 的資料
首先要去設定 openldap-client 的部份
# cd /usr/local/etc/openldap
# vi ldap.conf
BASE dc=ldap,dc=bojack,dc=com,dc=tw
URI ldap://ldap.bojack.com.tw ldap://ldap.bojack.com.tw:666
# ldapsearch -x -b "dc=ldap,dc=bojack,dc=com,dc=tw"
若有看到東西應該就 OK 了,這篇簡單說明 LDAP Server 架設的方式
本篇大部份都是參考 OpenLDAP-LDAP Server 基礎設定 此篇文章做設定,詳細的參數可以仔細閱讀一下
沒有留言:
張貼留言