smbldap-tools – 整合 Samba 與 LDAP (一)

9月 9th, 2010 由 Nica Leave a reply »
套件 smbldap-tools 目標是要用 Samba 與 LDAP 架設一個 Linux 部門伺服器,取代現有的 M$ Windows Domain Controller 伺服器,提供中央控管認證服務、檔案與列印共享,予 M$ Windows 與 Unix 的用戶端。因此要成就這些,必要的套件有:
  • OpenLDAP – 核心元件 openldap、客戶端套件 openldap-clients 與伺服器套件 openldap-servers
  • Samba – samba, samba-client 與 samba-common
  • nss_ldap 與 pam_ldap
  • smbldap-tools
.
smbldap-tools 屬於 samba.idealx.org 專案,而 idealx.org 已自動轉址為:http://www.opentrust.com/。它提供一整組 script,整合與管理 Samba 與 LDAP 目錄,雖然主要目標是 GNU/Linux 系統上的使用者與管理者,不過像 Solaris 或 AIX 這樣的 Unix 系統下也能運作。這些工具是用 perl 寫的,以 Red Hat 作業系統下為例,會位於 /usr/share/doc/samba-3.0.9/LDAP/smbldap-tools 下,提供的 perl script 有:
  • smbldap-groupadd.pl
  • smbldap-migrate-accounts.pl
  • smbldap-useradd.pl
  • smbldap-groupdel.pl
  • smbldap-migrate-groups.pl
  • smbldap-userdel.pl
  • smbldap-groupmod.pl
  • smbldap-passwd.pl
  • smbldap-usermod.pl
  • smbldap-groupshow.pl
  • smbldap-populate.pl
  • smbldap-usershow.pl
.
【設定 OpenLDAP】
組態 OpenLDAP 扮演 SAM 資料庫的角色,必須能夠:
.接受 Samba  LDAP v3 schema
.執行 base DN dc=xxx,dc=net
.含括執行所須的最基本 entry
為講解所需,必須用到下列 LDAP DIT (使用 Relative DN 符號表示式):
dc=xxx,dc=net
|
\ — ou=Users:存放 Unix 與 Windows 系統的使用者帳號
|
\ — ou=Computers:存放 Windows 系統的電腦帳號
|
\ — ou=Groups:存放 Unix 與 Windows 系統 ( 或其它 LDAP 支援的系統 ) 的系統群組
|
\ — ou=DSA:存放特殊帳號 (simpleSecurityObject)
.
這個 DIT 相容於 RFC 2307bis 所建議,不用 ou=Host 存放電腦帳號,原因是 TCP/IP 主機與 M$ Windows 電腦帳號是不同的。而 ou=DSA 則是用以存放 LDAP 用戶端的特殊安全性帳號。
管理者也可以選擇把所有帳號 (例如 shadowAccounts 與 sambaSAMAccounts) 全放在同一 DN 名稱下,此處選擇以 DIT 的方式單純是因為 RFC 2307bis 的建議,也因為這種方式比較便於理解。基本上配置的方式是:
.M$ windows 使用者帳號使用 sambaSAMAccount 物件類別 (samba.schema)
.M$ Windows 電腦帳號 (例如工作站) 使用 sambaSAMAccount 物件類別
.Unix 使用者帳號用 posixAccount objectclass 與 shadowAccount objectclass,以便 shadow 套件的 password 使用 (nis.schema)
.使用者群組使用 posixGroup 與 sambaGroupMapping 物件類別。
.軟體用戶端 (samba 與 Linux )的安全性帳號使用 simpleSecurityObject (core.schema) 物件類別。
.
samba schema 必須是 OpenLDAP 伺服器支援的,因此 /etc/openldap/slapd.conf 必須含括:
include         /etc/openldap/schema/core.schema
include         /etc/openldap/schema/cosine.schema
include         /etc/openldap/schema/inetorgperson.schema
include         /etc/openldap/schema/nis.schema
include         /etc/openldap/schema/samba.schema <== samba schema
inetOrgPerson objectclass 是為了讓組織與技術性資料合併,這麼作可以便於管理使用者帳號,讓它們可以用來定義:
.公司裡的某個人
.M$ Windows 與 Unix 系統的使用者帳號
.LDAP 認可之應用程式的使用者帳號
這個作法不是強制性的,可隨組織狀況,依需求調整之。
.
設定 slapd 伺服器為 suffix: dc=xxx,dc=net 的主伺服器:
database   bdb
directory  /var/lib/ldap
suffix     “dc=XXX,dc=NET”
rootdn     “cn=Manager,dc=XXX,dc=NET”
index      objectClass,uidNumber,gidNumber                  eq
index      cn,sn,uid,displayName                            pres,sub,eq
index      memberUid,mail,givenname                 eq,subinitial
index      sambaSID,sambaPrimaryGroupSID,sambaDomainName    eq
存取控制清單 – Access Control List 是用來保護電腦,建議設定:
access to attrs=userPassword,sambaLMPassword,sambaNTPassword
by self write
by anonymous auth
by * none
access to *
by * read
最後,指定伺服器的 Root DN 密碼:
rootpw          mysecretpwd
除了將 slapd.conf 檔案權限設為 600 保護 Root DN 密碼外,還可以設定 hash password 多一層防護,用 slappasswd 指令,產生 SSHA 或 MD5 演算法編碼過的一串文字:
[root@JNT ~]# slappasswd -h {MD5} -s csimiarmi
{MD5}omUIMFLj4+MgQFlIuuxJRA==
-h 指定 hash 演算法,可以用的有 CRYPT, MD5, SMD5, SSHA, 與 SHA,若未指定,預設為 SSHA。產生之後將該串文字 – 含 MD5 的部份,複製到 rootpw 後面即可。
.
用戶端組態在 ldap.conf 下,簡單設定即可:
HOST 127.0.0.1  <== 主機 IP
BASE dc=IDEALX,dc=ORG <== suffix
.
/etc/init.d/ldap start 啟動 LDAP 伺服器
照理來說應該可以順利啟動。若否,你可以:
.檢查你的組態檔
.除了 /etc/openldap/slapd.conf 外,還可以看看 /var/lib/ldap 目錄是否存在且下面的檔案屬於使用者 ldap。
.查詢 OpenLDAP 文件
(待續)
參考網站:
官方網站:

Advertisement

1 篇回應

  • At 2010.09.11 18:09, Sylar said:

    slapd.conf should be set to 640
    for sucessful start ldap service.

    (Required)
    (Required, will not be published)