歡迎您光臨本站 註冊首頁

openldap的安裝筆記,請大家多點關注ldap技術。

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

openldap的安裝筆記,請大家多點關注ldap技術。

openldap安裝筆記     

Ver 0.1   2004-4-7
作者:Jims
http://www.ringkee.com

註:我的安裝方法是以源碼編譯的方式進行的,以root用戶進行安裝。
安裝所需軟體
openldap-2.1.29                http://www.openldap.org
Berkeley DB 4.2.52        http://www.sleepycat.com

安裝步驟
1、由於openldap需要Berkeley DB來存放數據,所以需先安裝Berkeley DB 4.2.52,可到它的網站下載,網址見上面。
# tar -zxvf db-4.2.52.tar.gz
解完壓后,會生成一個db-4.2.52目錄,進行該目錄下的build_unix目錄。執行以下命令進行配置安裝。
# ../dist/configure
# make
# make install
也是按linux源碼安裝的三步曲完成,沒有什麼好說的了。該軟體默認是安裝在/usr/local/BerkeleyDB.4.2目錄下。安裝完成後,要把/usr/local/BerkeleyDB.4.2/lib的庫路徑加到/etc/ld.so.conf文件內,添加完成後執行一次ldconfig,使用配置文件生效。這樣編譯openldap時才能找到相應的庫文件。這樣資料庫就安裝完成了,接下來可以安裝openldap了。
ld.so.conf是什麼東西?它就是系統動態鏈接庫的配置文件。此文件內,存放著可被LINUX共享的動態鏈接庫所在目錄的名字(系統目錄/lib,/usr/lib除外),各個目錄名間以空白字元(空格,換行等)或冒號或逗號分隔。一般的LINUX發行版中,此文件均含一個共享目錄/usr/X11R6/lib,為X window窗口系統的動態鏈接庫所在的目錄。 ldconfig是它的管理命令,具體操作方法可查詢man手冊,這裡就不細講了。

2、到openldap官方網站下載最新的穩定版源碼,並解壓。查看INSTALLT 和README文檔,這個很重要,因為安裝方法和一些注意事項都在裡面有介紹。認真弄明白文檔內容能節省你不少的安裝調試時間。這也是開源軟體的一個特點,給用戶提供了最大的靈活性和可配置性。但也增加了系統安裝配置的難度,需要有相關的文檔配置說明和指導。在官方網站上還有詳細的幫助文件,在整個系統配置中需要經常查詢。
# tar -zxvf openldap-stable-20040329.tgz
解壓完成後,會生成一個openldap-2.1.29目錄。進行該目錄,執行以下命令進行配置安裝。
# env CPPFLAGS="-I/usr/local/BerkeleyDB.4.2/include" LDFLAGS="-L/usr/local/BerkeleyDB.4.2/lib" ./configure --prefix=/usr/local/openldap --enable-ldbm
注意以上配置語句,要設置資料庫的include和lib路徑,否則在配置到資料庫相關內容時會提示Berkeley DB版本不兼容,並中斷配置。如果沒有--enable-ldbm選項,在make test時會提示ldbm找不到。為了減少出錯,還是加上為好。
#make depens
#make
#make test
在make test階段要花費較長時間進行測試,好像有16項吧。你可以放鬆一下,上上網,聊聊天,聽聽歌,呵呵,開玩笑了,這個時間應該是最緊張的了。成不成就看這次的了。
#make install
通過配置命令可以看出,我們把openldap安裝到/usr/local/openldap目錄下。建議以源碼安裝的軟體都放到獨立的目錄下,不要放到軟體默認的目錄。好處是方便管理和控制,所有文件在統一的目錄下,卸載軟體只要刪除整個目錄就可以了。

3、ok,安裝完相關軟體后就可以著手配置了。Berkeley DB資料庫沒什麼好配置的。主要是配置openldap 服務。配置文件在軟體的安裝目錄的etc/openldap下,有四個文件,主要的是slapd.conf and ldap.conf,其它兩個是backup文件。首先,我們先來配置slapd.conf文檔。
系統默認的slapd.conf文件如下:
# $OpenLDAP: pkg/ldap/servers/slapd/slapd.conf,v 1.23.2.8 2003/05/24 23:19:14 kurt Exp $
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include         /usr/local/openldap/etc/openldap/schema/core.schema                設置schema配置文檔包含

# Define global ACLs to disable default read access.

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral       ldap://root.openldap.org

pidfile         /usr/local/openldap/var/slapd.pid                                 設置pid和args文檔位置
argsfile        /usr/local/openldap/var/slapd.args

# Load dynamic backend modules:
# modulepath    /usr/local/openldap/libexec/openldap
# moduleload    back_bdb.la
# moduleload    back_ldap.la
# moduleload    back_ldbm.la
# moduleload    back_passwd.la
# moduleload    back_shell.la

# Sample security restrictions
#       Require integrity protection (prevent hijacking)
#       Require 112-bit (3DES or better) encryption for updates
#       Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:
#       Root DSE: allow anyone to read it
#       Subschema (sub)entry DSE: allow anyone to read it
#       Other DSEs:
#       Subschema (sub)entry DSE: allow anyone to read it
#       Other DSEs:
#               Allow self write access
#               Allow authenticated users read access
#               Allow anonymous users to authenticate
#       Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
#       by self write
#       by users read
#       by anonymous auth
#
# if no access controls are present, the default policy is:
#       Allow read by all
#
# rootdn can always write!

#######################################################################
# ldbm database definitions
#######################################################################

database        bdb                                        設置使用的資料庫,也可用lbdm。
suffix          "dc=my-domain,dc=com"                        設置目錄後綴
rootdn          "cn=Manager,dc=my-domain,dc=com"        設置目錄管理員
# 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                                        設置管理密碼,這裡用了明文的secret密碼。
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory       /usr/local/openldap/var/openldap-data        設置資料庫路徑
# Indices to maintain
index   objectClass     eq                                設置目錄項索引

要伺服器正常動作,要修改一些始初參數和設置,修改後的配置文檔如下:

# $OpenLDAP: pkg/ldap/servers/slapd/slapd.conf,v 1.23.2.8 2003/05/24 23:19:14 kurt Exp $
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include         /usr/local/openldap/etc/openldap/schema/core.schema                為了有效使用目錄服務,包含相關的文件。
include         /usr/local/openldap/etc/openldap/schema/corba.schema                注意,在包含文件時是要按一定順序的,因為文件
include         /usr/local/openldap/etc/openldap/schema/cosine.schema                里的屬性存在依賴關係。如果順序不對,伺服器啟
include         /usr/local/openldap/etc/openldap/schema/inetorgperson.schema    動不了,文檔間的依賴關係在文檔中都有說明,請
include         /usr/local/openldap/etc/openldap/schema/misc.schema             仔細查看一個。如果懶得看也可以按我的順序。
include         /usr/local/openldap/etc/openldap/schema/openldap.schema
include         /usr/local/openldap/etc/openldap/schema/nis.schema
include         /usr/local/openldap/etc/openldap/schema/samba.schema
# Define global ACLs to disable default read access.

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral       ldap://root.openldap.org

pidfile         /usr/local/openldap/var/slapd.pid
argsfile        /usr/local/openldap/var/slapd.args

loglevel 1                        增加了日誌功能,需修改syslog配置文件,在文件中增加一項:local4.*         /var/log/ldap.log
                                日誌級別定義可查相官方網站的文檔。1級記錄的信息很多。可用於調試。
# Load dynamic backend modules:
# modulepath    /usr/local/openldap/libexec/openldap
# moduleload    back_bdb.la
# moduleload    back_ldap.la
# moduleload    back_ldbm.la
# moduleload    back_passwd.la
# moduleload    back_shell.la

# Sample security restrictions
#       Require integrity protection (prevent hijacking)
#       Require 112-bit (3DES or better) encryption for updates
#       Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:
#       Root DSE: allow anyone to read it
#       Subschema (sub)entry DSE: allow anyone to read it
#       Other DSEs:
#               Allow self write access
#               Allow authenticated users read access
#               Allow anonymous users to authenticate
#       Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
#       by self write
#       by users read
#       by anonymous auth
#
# if no access controls are present, the default policy is:
#       Allow read by all
#
# rootdn can always write!

#######################################################################
# ldbm database definitions
#######################################################################

database        bdb
suffix          "dc=it,dc=com"                改成你自已的目錄後綴,
rootdn          "cn=root,dc=it,dc=com"        設置root為管理員,與linux的root沒有什麼關係。
# Cleartext passwords, especially for the rootdn, should
# be avoid.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw          {MD5}mjkiuPt0wXhpxxkdiOOO+0000000AKq0by        設置root密碼,用MD5加密。密碼串用slappasswd -h {MD5}指令
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory       /usr/local/openldap/var/openldap-data   
# Indices to maintain
index   objectClass     eq        這裡可根據你的需要設置相關索引,以加快查詢速度。具體內容可查詢官方網站管理手冊。       

#ACL configure                        以下內容定義訪問控制
access to  attr=userPassword                                        userPassword只能由自已修改,有效驗證用戶查詢。
        by self write
        by anonymous auth
access to attr=mail
        by dn="cn=root,dc=it,dc=tigerhead" write                mail只能由自已修改,有效驗證用戶查詢。
        by self write
        by anonymous auth
access to dn=".*,dc=it,dc=tigerhead"                                允許所有人查詢沒受控制訪問限制的信息。
        by self write
        by * read
ok,到現在為止,伺服器基本就配置完成了,可以啟動了,伺服器程序是位於安裝目錄的libexec下的slapd程序。注意,不是sldap哦。
# ./slapd
如果沒有提示什麼出錯信息,直接返回shell狀態,就說明伺服器正常啟動了,你可以查詢日誌或用ps -aux查看。或用以下命令查詢伺服器。
ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
如果命令執行成功,返回一些信息,則說明伺服器正常運行了。如果啟動不成功,它會提示一些出錯信息,多數是slapd.conf配置出錯。回頭仔細核查一下配置文檔。

4、客戶端配置文檔是ldap.conf。該文檔相當簡單,其實不和配置也能正常操作。
# $OpenLDAP: pkg/ldap/libraries/libldap/ldap.conf,v 1.9 2000/09/04 19:57:01 kurt Exp $
#
# LDAP Defaults
#

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

BASE    dc=it, dc=com                設置目錄起點
#URI    ldap://ldap.example.com ldap://ldap-master.example.com:666

#SIZELIMIT      12
#TIMELIMIT      15
#DEREF          never

5、ok,伺服器正常運作后,就可以錄入信息了。信息的錄入有三種方法,一種是手工錄入,一種是.ldif文件格式錄入,一種是腳本自動錄入。我們先從最基礎的手工錄入方式開始介紹,了解錄入信息的格式。明白了手工錄入的格式,其它兩種方式都很容易明白。信息錄入用到ldapadd這個程序。可在安裝目錄的bin目錄下找到。具體用法如下:
第一步是要建立DN:
# ldapadd -x -D 'cn=root,dc=it,dc=com' -W
dn: dc=it,dc=com
objectClass: dcObject
objectClass: organization
dc: it
o: Corporation
description: d Corporation
注意:如果你用複製/粘貼功能把以上內容拷貝過去,一定要注意每行後面不要有空格。
第二步是建立RDN:
# ldapadd -x -D 'cn=root,dc=it,dc=com' -W        -x表示用簡單驗證,-D表示指定目錄,-W表示彈出密碼輸入提示
dn: uid=qq,dc=it,dc=com
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
uid: qq
cn: qq
sn: qq
telephoneNumber: 138888888
description: openldap test
telexNumber: tex-8888888
street: my street
postOfficeBox: postofficebox
displayName: qqdisplay
homePhone: home1111111
mobile: mobile99999
mail:qq@qq.com
輸入完所有信息后,按Ctrl+d結束存檔。如果出現出錯信息,請查一下對象類和屬性的對應關係有沒有錯或輸入失誤。初學者就容易出錯的地方是對象類和屬性的對應關係沒有處理好。對象類和屬性是在schema文檔中定義的。它們之間的關係是這樣的,對象類中有些屬性是必選的,有些屬性是可選的。錄入信息的屬性必須在對象類中有定義才能用。

輸入以下命令可查詢到剛才輸入的信息。
# ldapsearch -x -b 'dc=it,dc=com'        -b設置目錄起點,如果設置了BASE參數,該項可不用。
如果按以上配置文件設置了acl,用上面的查詢命令是查詢不到受保護的內容的。如上面的userPassword and mail。要查詢到這些受限內容,需要通過驗證才可以。
# ldapsearch -x -LLL -h it.com -b 'dc=it,dc=com' -D 'uid=qq,dc=it,dc=com' -W 'uid=qq'
接著提示輸入密碼。輸入userPassword的密碼回車,所有信息就都出來了。

.ldif文件方式也就是把以上手工輸入的內容先寫入一個.ldif文件中,然後,用ldapadd命令的-f參數導入。
# ldapadd -x -D "cn=root,dc=it,dc=com" -W -f test.ldif
一個完整的global.ldif文件例子:
dn: dc=info, dc=net
objectClass: top
objectClass: organization
o: info.net

dn: ou=People, dc=info, dc=net
objectClass: top
objectClass: organizationalUnit
ou: People
description: User Info

dn: cn=Admin, dc=info, dc=net
objectClass: top
objectClass: person
objectClass: organizationalPerson
cn: Admin
sn: Admin
userPassword: Admin
description: Administrator for info.net

dn: id=1, ou=people, dc=info, dc=net
objectclass: top
objectclass: InfoPerson
id: 1
username: 張三
tel:021-63138990
card_id:ABC001
再次提醒,注意每行後面不要留有空格。

腳本錄入方式需要自已編寫腳本,或到網上下載。有一個用PHP寫的LDAP管理工具不錯,叫phpLDAPadmin。可以到以下網址下載:
http://phpldapadmin.sourceforge.net/。安裝方法也很簡單,只要解壓出來,拷貝到apache的web目錄下,按說明配置一下設定文檔,就ok了。

接著為大家介紹一下幾個常用的ldap命令,如果你用了phpLDAPadmin程序,其實它已經有一個很好的圖形介面幫你完成這些命令了。但了解一下還是對你還是很有益的,因為命令方法才是最根本的。
1、刪除命令ldapdelete
# ldapdelete -x -D 'cn=root,dc=it,dc=com' -W 'uid=qq1,dc=it,dc=com'
2、設置使用者密碼,當然了,你的用戶需要有userPassword項了。
#ldappasswd -x -D "cn=root,dc=it,dc=com" -W "uid=qq1,dc=it,dc=com" -S
New password:
Re-enter new password:
Enter bind password:
Result: Success (0)
注意:"Enter bind password" 是 "cn=root,dc=it,dc=com"管理員的密碼。
3、管理員密碼更改
#slappasswd
New password
Re-enter new password
{SSHA}83DJ4KVwqlk1uh9k2uDb8+NT1U4RgkEs
接下來再拷到 /path/to/sldap.conf 的 rootpw 即可,重啟使用配置文件生效
4、通過ldapmodify修改目錄內容
ldapmodify -x -D "cn=root,dc=it,dc=com" -W -f modify.ldif
通過ldif文件修改ldap數據,ldif文件格式如下:
dn: cn=qq,dc=it,dc=com
changetype: modify
replace: mail
mail: modme@example.com
-
add: title
title: Grand Poobah
-
add: jpegPhoto
jpegPhoto:< file:///tmp/modme.jpeg
-
delete: description
-

啟用sasl驗證
前提是你在系統中安裝了sasl認證庫,並在編譯openldap時支持它,默認就支持了。到http://asg.web.cmu.edu/cyrus/下載。安裝方法見我寫的sendmail安裝筆記。
安裝好之後,需要在sasl中建立相應的帳號,用以下命令可完成。
# saslpasswd2 -c test

接著配置slapd.conf文件,加入以下內容。
sasl-regexp
        uid=(.*),cn=.*,cn=auth
        uid=$1,dc=it,dc=com
ok,重啟伺服器使配置文件生效。這個配置是最大許可權的配置,如果要細化請查閱相關文檔。
用以下命令測試。
# ldapsearch -U qq  -b 'uid=qq,dc=it,dc=com' -D 'dc=it,dc=com' -Y DIGEST-MD5                採用digest-md5驗證
提示密碼,輸入saslpasswd2的密碼。
???用sasl作驗證的作用還不是很清楚。

配置複製伺服器
由於沒有配置兩台伺服器,所以還沒有測試。



參考網站
http://www.openldap.org/doc/admin22/
http://asg.web.cmu.edu/cyrus/
http://phpldapadmin.sourceforge.net/
http://www.linux.org/docs/ldp/howto/LDAP-HOWTO/index.html
http://www.linux.org/docs/ldp/howto/LDAP-Implementation-HOWTO/index.html
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

你這篇,都沒我去年貼的詳細。

phpldapadmin沒有LDAP Browser/Editor好用
schema也沒講。沒有schema,ldap寸步難行。
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

一個筆誤,請把所有dc=tigerhead替換成dc=com,這樣前後才一致。
本文只是我安裝openldap的過程筆記匯總。如果要詳細介紹ldap,可能要出一本幾百頁的書了,呵呵。我也是剛剛接觸ldap技術,很多技術細節還沒了解透砌。以前只是聽說過或在一些系統上看到過ldap的一些設置,沒有具體去了解它。現在由於我公司計劃做單點登錄。所以花了一個星期左右的時間安裝了一個openldap伺服器,用於測試。總體感覺ldap技術是一個好東西來的,由於它基於開放的Internet標準,能和很多技術集成使用。如果我們能進一步開發應用,將會在企業的信息集成方面大有作為。
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

good.

any detail setup for setup a group of server and all users login authentication through LDAP ?
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

設置備份伺服器比較簡單,主要是在slapd.conf文件里做一下設置。利用ldap做為用戶驗證伺服器我還沒測試過。不過有一篇介紹利用ldap進行users login authentication的文章不錯。可以介紹給你參考一下。

OpenLDAP - User Authentication
by Shell Hung <shell@shellhung.org>;
  
  
剛剛到學校工作時,因為主要的工作之一是負責兩台 Linux Server 的運作,很多謝管理校內 IT 工作的鐘老師給了我管理的權力,讓我可以有機會完成很多系統上的轉換及更新等程序。

由於在我入職前,已經有兩台運作 Debian GNU/Linux 的伺服器,而我當然利用了我對 Debian GNU/Linux 少少的認識對系統運作進行了不少的改進。原有的問題是賬戶太多,難以更新,試想,每一位老師、職工及學生都有一個電郵賬戶,每年學期初的賬戶更新程序太多,所以我最初先使用了 NIS 作為認証,由一台伺服器做這個工作,另一台只負責 SMTP、POP3及IMAP的工作。

初時,這個模式運作不會有問題,往後管理問題亦不大,但是,我漸漸為電腦部門編寫一系列的網上管理程式,例如有房間借用、更改密碼、學生資料、存貨清單管理等等,全都需要有一定的認証,而我所採用的方法就是放棄 NIS而改用 LDAP。

以下就是我在兩台 Debian GNU/Linux 上及其他 Linux Notebook 所做有關使用 LDAP 作用者資料庫等的方式,而有關 OpenLDAP 的背境資料實在太複雜了,所以我不打算在此說明,而且,對 LDAP 應用方面亦各有不同,所以只為取代 NIS 及作為中央認証程序記下過程,以供其他人參考。

選擇一台伺服器作為 LDAP Server,然後執行:

# apt-get install slapd ldap-utils migrationtools

請參考以下數個圖片,這些圖片是特地為這份文件,而在我使用的 Debian 工作站上安裝設定而抓下的。


回答為


回答為


在 LDAP 結構中,這個 Domain Name 會變為 "dc=yourdomain,dc=com"。


這個是 LDAP admin (cn=admin,dc=yourdomain,dc=com) 的密碼,對整個 LDAP 的資料樹都有寫入的權限,為安全理由,不要與 root 使用同一個密碼。


這個問題只回答 便可以,否則您還用看這份文件麼?




OpenLDAP 的主要設定檔在 /etc/ldap/slapd.conf,基本上,如不是為了設定 Authentication Gateway,這個檔案便不須要修改,LDAP 已經可以運作了,但是為了文件主題,我們還是要為檔案作很多修改。

把用作控制清單的部份分開到另一檔案內可以使管理變得集中,這亦是我的個人習慣,其他人也可以不跟從。在 slapd.conf 內更改為:


# Schema and objectClass definitions
include          /etc/ldap/schema/core.schema
include          /etc/ldap/schema/cosine.schema
include          /etc/ldap/schema/nis.schema
include          /etc/ldap/schema/inetorgperson.schema

# Our Access Control
include                /etc/ldap/slapd.acl




最後把檔案尾部份 "access to" 等的兩大段全部刪去,然後建立 /etc/ldap/slapd.acl 檔案,把檔案權限改為最多 0640,然後把以下的資料放進 slapd.acl 檔案內:


access to attribute=userPassword
         by dn="cn=admin,dc=yourdomain,dc=com" write
         by dn="cn=proxyuser,dc=yourdomain,dc=com" read
         by anonymous auth
         by self write
         by * none

access to *
         by dn="cn=admin,dc=yourdomain,dc=com" write
         by * read

access to dn=".*,dc=yourdomain,dc=com" attr=userPassword
         by dn="cn=admin,dc=yourdomain,dc=com" write
         by dn="cn=proxyuser,dc=yourdomain,dc=com" read
         by self write
         by * auth

access to dn=".*,dc=yourdomain,dc=com" attr=mail
         by dn="cn=admin,dc=yourdomain,dc=com" write
         by dn="cn=mailuser,dc=yourdomain,dc=com" write
         by self write
         by * read

access to dn=".*,ou=People,dc=yourdomain,dc=com"
         by * read

access to dn=".*,dc=yourdomain,dc=com"
         by self write
         by * read

有關這些 "access to" 或是甚麼 "self write" 甚麼 "attr=" 這些東東,請各位看 slapd.conf 的系統手冊,現在不是要讓大家認識甚麼是 LDAP,或是怎樣設定 OpenLDAP,只是一份設定 OpenLDAP Authentication Gateway 的筆記吧!

當中特別的兩點是 "proxyuser" 及 "mailuser", "proxyuser" 對用者的密碼是只有 read 的權力,這個用者是用在與 LDAP 溝通,認証用者密碼的特別用者,一般都會命名為 proxyuser;而 mailuser 功能與 proxyuser 相同,只是所用的地方與 proxyuser 不同。

現在就是轉移的過程,這個步驟是把系統原用的如 /etc/shadow、/etc/group 等檔案轉換為 LDAP 的 LDIF 格式,然後匯入到 LDAP 資料庫內。我們已經安裝了 migrationtools,所有檔案都安裝在 /usr/share/migrationtools/ 內,但是在這之前,還有一個檔案須要設定: /etc/migrationtools/migrate_common.ph。

這個 migrate_common.ph 是整個 migrationtools 的設定檔案,只須要更改以下兩個 Perl 變數為您的須要便可:


# Default DNS domain
$DEFAULT_MAIL_DOMAIN = "yourdomain.com";

# Default base
$DEFAULT_BASE = "dc=yourdomain,dc=com";

現在,我們可以建立一個暫存的目錄,例如 /etc/ldap/tmp,然後把所有在 migrationtools 目錄內的檔案複制進去。再依次執行以下的指令:

./migration_base.pl >; base.ldif
./migration_hosts.pl /etc/hosts >; hosts.ldif
./migration_group.pl /etc/group >; group.ldif
./migration_passwd.pl /etc/passwd >; passwd.ldif
執行後,然後查看四個已建立的檔案,把不需要的部份刪去,例如不想放在 LDAP 內的用者或是群組等等,確定好沒有問題後,先把 /var/lib/ldap 備份,這是最原始的 LDAP 資料樹結構,假若在新增資料時出現問題,只需用備份覆過去再重新啟動 slapd 便可以。

現在為 proxyuser 及 mailuser 建立 LDIF 並加入在 passwd.ldif 檔案內,請參考以下的 LDIF 格式:


dn: cn=proxyuser,dc=yourdomain,dc=com
cn: proxyuser
sn: proxyuser
objectClass: top
objectClass: person
userPassword: {MD5}6AtQFwmJUPxYqtg8jBSXjg==

dn: cn=mailuser,dc=yourdomain,dc=com
cn: mailuser
sn: mailuser
objectClass: top
objectClass: person
userPassword: {MD5}hl9cx/vXhUkC6unYIR8Xig==

而 userPassword 內的密碼可以使用 "slappasswd -h {MD5}" 指令建立。接著新增 LDIF 格式的檔案進 LDAP 內:


for i in *.ldif; do
        ldapadd -x -D "cn=admin,dc=yourdomain,dc=com" -w -f $i.ldif
done




然後可以進行測試,執行以下的指令,如果 ldapsearch 可以找出用者的密碼便為成功:


# ldapsearch -LL -h -b "dc=yourdomain,dc=com" -W -x        \
  -D "cn=proxyuser,dc=yourdomain,dc=com" "(uid=username)" userPassword

那就是使用 中的資料庫,以 "dc=yourdomain,dc=com" 為 BASE 作搜尋,並以 "cn=proxyuser,dc=yourdomain,dc=com" 這個用者執行動作,找出 (uid=username) 的用者及其密碼 (userPassword)。結果會類似以下:


version: 1

dn: uid=username,ou=People,dc=yourdomain,dc=com
userPassword:: e2NyeXB0fsQxJEVQn0gwnfh3JHJ4UjV1lUhikwdnHjRWVAeU5oZjBweDE=

現在來設定客端,客端設定亦很簡單,須要的只是兩個包件:

# apt-get install libnss-ldap libpam-ldap


回答 LDAP 的 LDAP URI 或是 Host IP Address


回答 LDAP 的 Base DN


回答 LDAP 的版本為 "3"


proxyuser 是需要密碼才可以通過的


設定 /etc/ldap.secret 檔案只為 root 才可以看到


填入 proxyuser 的 binddn


填入 proxyuser 的 password




最後就是修改 /etc/nsswitch.conf 檔案,這個檔案控制系統找取用者資料及 Hostname 等的來源,原來的檔案是類似這樣的:


passwd:         compat
group:          compat
shadow:         compat

hosts:          files dns

現在修改為:


passwd:         ldap
group:          ldap
shadow:         ldap

hosts:          files ldap dns

修改了 nsswitch.conf 檔案後,現在最後要做的就是設定 pam 可以使用 LDAP。在 libpam-ldap 包件內附帶了一個 pam.conf 檔案,可以把檔案複制到 /etc 內,把不用的 pam 模組刪去便可以。有關的設定已經完成,餘下的設定只是針對 PAM 模組及系統如 Hostname 等的個別環境設定,請自行參考有關的文件,本筆記亦不再詳解。在 migrationtools 內還有其他的工具,用法都是一樣,如 Aliases 及 fstab 等的支援都有,也可按個別須要而建立。

有關這份文件的錯誤,可與本人聯絡,也歡迎意見及改進,如若依法設定成功,不妨給本人一個電郵通知,或是多做善事積善功也可。
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

能講講LDAP的應用和前景嗎?

我聽說LDAP是比較早的技術./
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

very good article, thank you very much.

do you got any idea what kind of SMTP server is best for LDAP mail routing ? i did consider Sendmail but dont know will Postfix or Qmail got better support for LDAP.
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

sorry,yongpeng.我也是剛接觸mail server and ldap。所以談不上那種smtp server和ldap技術結合得最好。但這三種mail server都有各自的優缺點。是好,是壞主要還是要看你的具體應用水平,對這些server你了解多少,能否很好地使用它。
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

始終沒有搞定輸入中文字元到LDAP里

有招否?
《解決方案》

openldap的安裝筆記,請大家多點關注ldap技術。

thx yjnet

[火星人 ] openldap的安裝筆記,請大家多點關注ldap技術。已經有1076次圍觀

http://coctec.com/docs/service/show-post-16394.html