7.1: 身份識別與檔案系統間的關係
7.2: LDAP 簡介
7.3: LDAP 的實際設定流程
7.4: LDAP 資料庫簡易管理 (新增/刪除/修改用戶參數)
7.5: 分享檔案系統的 NFS 伺服器
DN,Distinguished Name:識別名稱,LDAP 中一筆記錄的位置
RDN,Relative Distinguished Name:相對識別名稱,CN 及 CN 的值。例如:cn=deyu 獨一無二的屬性。
CN,Common Name/uid:顯示名稱,一筆 LDAP 記錄的名字/ID
OU,Organizational Unit:組織,一筆 LDAP 記錄所屬組織
DC,Domain Componet:網域元件,一筆 LDAP 記錄所屬區域
- 基本上,你就將 LDAP 想成是一個目錄,而每個目錄都有個目錄名稱,然後根據不同需求,可以給予更多的目錄節點
- 單純以節點的角度來看,以一個公司名稱為『 example.com 』的位置來說,該公司的相關部門位置節點有點像這樣
- 如上所示,公司底下有兩個部門 (organization unit),一個是伺服器部門 (Servers) 一個是人資部門 (People) ,其中人資部門底下管理著員工證號 (Person, udid), 大概就是這樣一層一層的分配下來~而每一個節點底下可以搭配不同的資料給予特別的任務就是了。
- 因此,只要找尋不同的 location 即可取得各自部門的人資訊息
Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
昱齊 先用dc來表達公司的FQDN,再用ou來指公司底下的組織單位,dc+ou也就是一種dn
如果確定要架設 LDAP 作為你的身份驗證來源,那麼你得要事先規劃好這部 LDAP 所提供的 baseDN、相關的管理者密碼、相關的帳號 UID 起始號碼、 相關的使用者家目錄 (最好不要跟系統預設的 /home 相同位置,否則容易造成本機帳號與網路帳號衝突的狀況)等等。至於一般的架設流程大概是這樣的:
為了避免 Server/client 之間名稱解析產生的連線延遲,因此 IP 對應主機名稱最好還是寫入 /etc/hosts 較佳
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.254.xxx pcxxx.dic.ksu pcxxx
192.168.254.254 pc254.dic.ksu pc254
10.255.xxx.254 server.lanxxx.dic.ksu server <==這個項目
10.255.xxx.1 client.lanxxx.dic.ksu client <==這個項目
要能夠執行 LDAP server 至少也需要 openldap-servers, openldap-clients, openldap 等軟體才行~不過,後續我們會用到 Linux 帳號轉成 LDAP 帳號的機制, 那就得要額外安裝 unix 帳號轉 ldap 帳號的轉換腳本 migrationtools 這個軟體才行!
netstat
[root@localhost ~]# ldapadd -x -W -D "${RootDN}" -f LDIf_filename
[root@localhost ~]# ldapadd -x -W -D "cn=Manager,dc=dic,dc=ksu" -f /root/ldap/base.ldif
這裡說明一下 LDAP 主要的簡稱含義:
DIT(Directory Information Tree;目錄資訊樹)
o - organization (組織)
ou - organization unit (組織單位-部門)
c - country Name (國家)
dc - domain Component (域名)
sn - suer name (真實姓名)
cn - common name (使用者名稱)
dn - Distinguish Name (識別名稱)
修改slapd.conf
suffix "dc=mp,dc=nttu,dc=edu,dc=tw"
rootdn "cn=username,dc=mp,dc=nttu,dc=edu,dc=tw"
表示法
表示出towns在LDAP的唯一識別名稱(DN)
cn=username, cn=cy, cn=unit, cn=company, dc=mp,dc=nttu,dc=edu,dc=tw
LDAP的識別方式與DNS類似,由小排大
在CentOS7上安裝OpenLDAP Server
一、 安裝套件
安裝 openLDAP 套件
# yum -y install openldap*
2. 安裝 migrationtools 工具
# yum install migrationtools
二、 清除範例資料並新增目錄與設定檔
清除範例資料
# rm -rvf /etc/openldap/slapd.d
2. 建立目錄
# mkdir /etc/openldap/slapd.d
3. 複製設定的範例檔
# cp /usr/share/openldap-servers/slapd.ldif /etc/openldap/slapd.conf
三、 設定管理密碼並查看
切換到openldap
# cd /etc/openldap
2. 設定密碼並輸出到文字檔,方便以 tail 查看
# slappasswd > password.txt
3. 查看{SSHA}密碼並複製到記事本備用
# tail password.txt
四、 編輯設定檔
編輯 slapd.conf 主要控制的設定檔
# nano /etc/openldap/slapd.conf
把所有的dc=my-domain,dc=com改成dc=mp,dc=nttu,dc=edu,dc=tw
然後結尾補上
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxx
(從剛剛記事本那邊貼過來)