資料來源官方網站: http://www.skills-1st.co.uk/papers/ldap-schema-design-feb-2005/index.html
官方網站資料下載連結: http://www.skills-1st.co.uk/papers/ldap-schema-design-feb-2005/ldap-schema-design-feb-2005.pdf
站內搜尋:Yahoo搜尋的結果,如果沒有給完整的網址,請在站內再搜尋一次!
2011-10-18
2011-10-17
2011-10-16
使用JXplorer來查詢所連接的LDAP server有哪些objectClasses可以選用?每個objectClass又包含了哪些Attributes(屬性)?
在前一篇『在ubuntu下,使用webmin管理OpenLDAP』中,曾提到使用JXplorer(http://jxplorer.org/)來測試與OpenLDAP間的連線。JXplorer是一個很棒的LDAP工具軟體,在建構與管理LDAP的過程,JXplorer可以提供很大的幫忙!
確認正確安裝OpenLDAP後,最重要的一件事,就是根據需求建構LDAP,但要如何配置?該引用哪些objectClasses呢?
JXplorer提供了Schema(綱要)瀏覽的功能,連上LDAP server後,即可透過JXplorer瀏覽有哪些objectClasses可以選用?每個objectClass又包含了哪些Attributes?
根據上圖:
在左側的選單欄,選擇『綱要』這個分頁頁籤,選擇Schema下的objectClasses,在objectClasses這個節點下,列出了目前可以使用的objectClass。
以圖例中這個account objectClass為例:
確認正確安裝OpenLDAP後,最重要的一件事,就是根據需求建構LDAP,但要如何配置?該引用哪些objectClasses呢?
JXplorer提供了Schema(綱要)瀏覽的功能,連上LDAP server後,即可透過JXplorer瀏覽有哪些objectClasses可以選用?每個objectClass又包含了哪些Attributes?
根據上圖:
在左側的選單欄,選擇『綱要』這個分頁頁籤,選擇Schema下的objectClasses,在objectClasses這個節點下,列出了目前可以使用的objectClass。
以圖例中這個account objectClass為例:
- attribute type為MUST,表示這個資料屬性欄位必須輸入資料。
- attribute type為MAY,表示這個資料屬性欄位沒有強制要輸入資料。
2011-10-13
在ubuntu下,使用webmin管理OpenLDAP
Webmin的ldap-server模組,只是在webmin下管理LDAP的一個模組,不能透過ldap-server模組來安裝LDAP伺服器,所以在使用webmin的ldap-server模組之前,要先確定已經安裝LDAP server。
在Ubuntu server下安裝OpenLDAP指令:(假設使用root登入,非root登入,需前置sudo指令)
apt-get update
apt-get install slapd ldap-utils
在webmin下安裝ldap-server管理模組:
webmin -> Webmin Configuration -> Webmin Modules
在Webmin Modules的Install分頁頁籤下,Install from 選擇:Standard module from www.webmin.com,再透過旁邊的『...』鈕,選取:ldap-server,執行:Install Module
安裝完成後,記得重新整理模組(Refresh Modules),在『Servers』這個項目下就會有『LDAP server』的選項,可以選擇。
選擇:OpenLDAP Server Configuration,確認→Root DN for LDAP database 以及 Administrator login DN 已建立。 必要時設定一下Administration password。
從遠端用JXplorer試著登入OpenLDAP:
確認是否可以成功連線登入?
在Ubuntu server下安裝OpenLDAP指令:(假設使用root登入,非root登入,需前置sudo指令)
apt-get update
apt-get install slapd ldap-utils
在webmin下安裝ldap-server管理模組:
webmin -> Webmin Configuration -> Webmin Modules
在Webmin Modules的Install分頁頁籤下,Install from 選擇:Standard module from www.webmin.com,再透過旁邊的『...』鈕,選取:ldap-server,執行:Install Module
安裝完成後,記得重新整理模組(Refresh Modules),在『Servers』這個項目下就會有『LDAP server』的選項,可以選擇。
選擇:OpenLDAP Server Configuration,確認→Root DN for LDAP database 以及 Administrator login DN 已建立。 必要時設定一下Administration password。
從遠端用JXplorer試著登入OpenLDAP:
確認是否可以成功連線登入?
2011-09-04
VB.net 連接 LDAP 的程式碼範例及解說
- 在透過程式碼連接存取LDAP,先了解一下LDAP對使用者存取的限制,掌握了存取限制的性後,對於程式碼的編寫,有非常大的幫助。
- 以下要說明的LDAP存取,具有以下的特性:
每個使用者的User DN,所在的路徑是不一定的,例如:
uid=user01,ou=dept1,ou=people,dc=abc,dc=edu,dc=tw
uid=user21,ou=dept11,ou=dept1,ou=people,dc=abc,dc=edu,dc=tw
uid=user55,ou=dept36,ou=dept5,ou=people,dc=abc,dc=edu,dc=tw
系統提供一個檢視瀏覽LDAP內容的User DN
LDAP主機使用Linux的OpenLDAP,ou可能會使用中文來命名
- 在專案中的『My Project』的『參考』加入:System.DirectoryServices
- 定義一個字串,設定LDAP主機的所在位置(LDAP://ldap.abc.edu.tw/),及登入預設的Base DN位置 (ou=people,dc=abc,dc=edu,dc=tw)
Dim strLDAP as String = "LDAP://ldap.abc.edu.tw/ou=people,dc=abc,dc=edu,dc=tw" - 將系統提供可以檢視瀏覽LDAP內容的User DN,定義為一個字串
Dim strUID as String = "uid=xadmin,ou=people,dc=abc,dc=edu,dc=tw" - 定義上述strUID所對應的密碼字串
Dim strPWD as String = "password" - 定義並初始化一個LDAP物件,並使用LDAP系統提供的帳號登入
Dim oLdapEntry As DirectoryEntry = New DirectoryEntry(strLDAP, strUID, strPwd, AuthenticationTypes.ServerBind) - 使用LDAP系統提供的帳號登入成功後,再定義初始化一個LDAP搜尋物件
Dim oLdapSearcher As DirectorySearcher = New DirectorySearcher(oLdapEntry) - 將要進行LDAP驗證的使用者帳號、密碼,定義如下:
Dim strUserID as String = "UserAcc"
Dim strUserPWD as String = "UserPwd" - 將進行LDAP登入驗證的使用者,設定為一個搜尋字串
oLdapSearcher.Filter = "(uid=" & strUserID & ")" - 定義並初始化,以使用者搜尋字串,所取得的搜尋結果
Dim oSearchResult As SearchResult = oLdapSearcher.FindOne - 如果可以取得搜尋結果,再從搜尋結果中,取得這個使用者在LDAP伺服器的User DN路徑
Dim strUserLdapPath As String = oSearchResult.Path.ToString
結果的字串範例:
LDAP://ldap.abc.edu.tw/uid=UserAcc,ou=dept1,ou=people,dc=abc,dc=edu,dc=tw - 接下來要利用strUserLdapPath這個字串來組合出,要以使用者身分登入的基本資料:
Dim strUserUid As String = strUserLdapPath.Replace("LDAP://ldap.abc.edu.tw/", "")
將LDAP://ldap.abc.edu.tw/uid=UserAcc,ou=dept1,ou=people,dc=abc,dc=edu,dc=tw這個字串中的LDAP://ldap.abc.edu.tw/移除,就可以得到這個User的 User DN。 - 將strUserLdapPath字串中,所取得的字串內容,移除uid相關內容,就可以取得這個使用者要登入的LDAP網址及Base DN
Dim strUserDN As String = strUserLdapPath.Replace("uid=" & strUserID & ", ", "") - 使用上述取得的strUserUid及strUserDN(即:使用者的身分)登入LDAP
Dim oUserLdapEntry As DirectoryEntry = New DirectoryEntry(strUserDN, strUserUid, strUserPWD, AuthenticationTypes.FastBind) - 確認oUserLdapEntry已成功初始化,以使用者帳號密碼,向LDAP伺服器進行存取的驗證,就算成功了...
AuthenticationTypes可以使用的成員,如下述:
參考:http://msdn.microsoft.com/zh-tw/library/system.directoryservices.authenticationtypes%28v=vs.80%29.aspx
| 成員名稱 | 說明 | |
|---|---|---|
| Anonymous | 未執行驗證。 | |
| Delegation | 啟用 Active Directory 服務介面 (ADSI) 來委派使用者安全性內容,將物件橫跨網域移動時會需要這項內容。 | |
| Encryption | 將加密簽章附加至訊息,該簽章會識別傳送者,並確保訊息不會在傳送時遭受修改。 | |
| FastBind | 指定 ADSI 不會嘗試查詢 Active Directory objectClass 屬性。因此,只會公開 (Expose) 所有 ADSI 物件都支援的基底介面。該物件所支援的其他介面則不可用。使用者可以用這個選項,來提高只涉及基底介面方法的一系列物件管理效能。不過,ADSI 不會確認所要求的物件是否確實存在於伺服器上。如需詳細資訊,請參閱 MSDN Library (http://msdn.microsoft.com/library/cht) 中的<可進行批次寫入/修改作業的快速繫結選項>主題 (英文)。如需 objectClass 屬性的詳細資訊,請參閱 MSDN Library (http://msdn.microsoft.com/library/cht) 中的 Object-Class 主題。 | |
| None | 等於零,意味著在 LDAP 提供者中使用基本驗證 (簡單連結)。 | |
| ReadonlyServer | 對於 WinNT 提供者來說,ADSI 會嘗試連接至網域控制站。對於 Active Directory 來說,這個旗標指示無伺服器繫結並不需要可寫入的伺服器。 | |
| Sealing | 使用 Kerberos 加密資料。同時 Secure 旗標必須設定為使用密封。 | |
| Secure | 要求安全驗證。當這個旗標設定時,WinNT 提供者會使用 NTLM 驗證用戶端。Active Directory 會使用 Kerberos 驗證用戶端,也可能使用 NTLM 驗證。當使用者名稱和密碼為 null 參考時 (在 Visual Basic 中為 Nothing),ADSI 會使用呼叫執行緒的安全性內容繫結至物件,它是應用程式在其下執行之使用者帳戶的安全性內容,或者是模擬呼叫執行緒之用戶端使用者帳戶的安全性內容。 | |
| SecureSocketsLayer | 將加密簽章附加至訊息,該簽章會識別傳送者,並確保訊息不會在傳送時遭受修改。Active Directory 需要有安裝憑證伺服器,才能支援 Secure Sockets Layer (SSL) 加密。 | |
| ServerBind | 如果您的 ADsPath 包括伺服器名稱,則在使用 LDAP 提供者時指定這個旗標。請不要為包括網域名稱的路徑或無伺服器路徑使用這個旗標。指定伺服器名稱時不指定這個旗標會導致不必要的網路流量。 | |
| Signing | 確認資料的完整性,以確保所接收的資料與傳送的資料相同。同時 Secure 旗標必須設定為使用簽名。 |
2011-08-07
在ubuntu上安裝OpenLDAP
參考資料:
https://help.ubuntu.com/11.04/serverguide/C/openldap-server.html
https://help.ubuntu.com/10.04/serverguide/C/openldap-server.html
https://help.ubuntu.com/11.04/serverguide/C/openldap-server.html
https://help.ubuntu.com/10.04/serverguide/C/openldap-server.html
- 安裝OpenLDAP的daemon程式 slapd 及 ldap-utils
sudo apt-get install slapd ldap-utils - 再加入一些schema的檔案:
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif
在ubuntu11.04版中,應該已加入以上三個schema,所以會出現 Duplicate attributeType的訊息。 - 建立以下的LDIF檔案內容(backend.example.com.ldif),將檔案存放在自行指定的位置:
# Load dynamic backend modules
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulepath: /usr/lib/ldap
olcModuleload: back_hdb
# Database settings
dn: olcDatabase=hdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: {1}hdb
olcSuffix: dc=example,dc=com
olcDbDirectory: /var/lib/ldap
olcRootDN: cn=admin,dc=example,dc=com
olcRootPW: secret
olcDbConfig: set_cachesize 0 2097152 0
olcDbConfig: set_lk_max_objects 1500
olcDbConfig: set_lk_max_locks 1500
olcDbConfig: set_lk_max_lockers 1500
olcDbIndex: objectClass eq
olcLastMod: TRUE
olcDbCheckpoint: 512 30
olcAccess: to attrs=userPassword by dn="cn=admin,dc=example,dc=com" write by anonymous auth by self write by * none
olcAccess: to attrs=shadowLastChange by self write by * read
olcAccess: to dn.base="" by * read
olcAccess: to * by dn="cn=admin,dc=example,dc=com" write by * read - 使用以下指令,將backend.example.com.ldif新增到LDAP中:
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f backend.example.com.ldif - 建立以下的LDIF檔案內容(frontend.example.com.ldif),將檔案存放在自行指定的位置:
# Create top-level object in domain dn: dc=example,dc=com objectClass: top objectClass: dcObject objectclass: organization o: Example Organization dc: Example description: LDAP Example # Admin user. dn: cn=admin,dc=example,dc=com objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin description: LDAP administrator userPassword: secret dn: ou=people,dc=example,dc=com objectClass: organizationalUnit ou: people dn: ou=groups,dc=example,dc=com objectClass: organizationalUnit ou: groups dn: uid=john,ou=people,dc=example,dc=com objectClass: inetOrgPerson objectClass: posixAccount objectClass: shadowAccount uid: john sn: Doe givenName: John cn: John Doe displayName: John Doe uidNumber: 1000 gidNumber: 10000 userPassword: password gecos: John Doe loginShell: /bin/bash homeDirectory: /home/john shadowExpire: -1 shadowFlag: 0 shadowWarning: 7 shadowMin: 8 shadowMax: 999999 shadowLastChange: 10877 mail: john.doe@example.com postalCode: 31000 l: Toulouse o: Example mobile: +33 (0)6 xx xx xx xx homePhone: +33 (0)5 xx xx xx xx title: System Administrator postalAddress: initials: JD dn: cn=example,ou=groups,dc=example,dc=com objectClass: posixGroup cn: example gidNumber: 10000
- 使用以下指令,將frontend.example.com.ldif新增到LDAP中:
sudo ldapadd -x -D cn=admin,dc=example,dc=com -W -f frontend.example.com.ldif - 使用ldapsearch測試一下
ldapsearch -xLLL -b "dc=example,dc=com" uid=john sn givenName cn
JXplorer : Java Ldap Browser
- 官方網站:http://jxplorer.org/
- 我選擇下載Pure Java的版本,直接解壓縮,點選jxplorer.bat或jxplorer.sh,就可以使用了...
- 一般LDAP使用389port
2011-02-11
[LDAP vs PHP]:使用php連接LDAP,進行資料的新增、刪除、修改、查詢...
php提供了許多的LDAP相關的函數,可以透過這些函數,連接LDAP server,並進行資料的管理維護作業,如果沒有一套LDAP的管理工具,也懂得PHP,可以考慮自己寫php的程式,來管理ldap。除了以下的函數,還有更多的函數可以選用...
※ LDAP search filter syntax基本語法:
本文原由作者本人於 2010-07-04 整理發表於 http://bod.tw/modules/tadnews/index.php?nsn=23
- 確定php的LDAP support已enabled 。
- 使用 ldap_connect(hostname, port) 連接LDAP,傳回值為一resource id。
- 使用 ldap_bind(link_identifier, bind_dn, bind_password) 登入LDAP,傳回值為bool值。
- 使用 ldap_search(link_identifier, base_dn, filter, attributes, ...) 取得查詢值,傳回值為 resource id。
- 使用 ldap_get_attributes(link_identifier, result_entry_identifier) 取得查詢結果的資料,傳回值為array。
- 使用 ldap_modify(link_identifier, dn, entry) 進行資料修改,傳回值為bool值。
- 使用 ldap_mod_add(link_identifier, dn, entry) 進行資料新增,傳回值為bool值。
- 使用 ldap_mod_del(link_identifier, dn, entry) 進行資料刪除,傳回值為bool值。
- 使用 ldap_mod_replace(link_identifier, dn, entry) 進行資料修改,傳回值為bool值。
※ LDAP search filter syntax基本語法:
- 語法參考:RFC2254 The String Requesentation of LDAP Search Filter
- 例一:(|(cn=HannibalHuang)(cn=HuangHannibal))
- 例二:(|(cn=HannibalHuang)(&(ou=People)(cn=HuangHannibal)))
本文原由作者本人於 2010-07-04 整理發表於 http://bod.tw/modules/tadnews/index.php?nsn=23
[LDAP入門]:如何自行定義openLDAP 的 objectClass?
- 存放objectClass schema的目錄位置:/etc/openldap/schema/
- 在所擁有的oid下,續編內部使用的自行定義objectClass。 查詢研考會的oid網站,http://oid.nat.gov.tw ,可以知道目前組織的oid為何?例: 2.16.886.111.123456,其中 2.16.886是台灣的國碼,2.16.886.111是學校分類...
- 在 oid網站也可查到一組DN,可以考慮用這組dn當作rootdn來作延伸續編...,所提供的dn編碼原則是:o=中文的組織公司名稱,c=tw。 這是採用geographic naming的方式,如果往後採用這個當基礎,每個DIT(data information tree)上的DN, 都要在這個基礎上繼續累加上去,o=中文的組織公司名稱,很明顯的太長了一點,BDN(base dn)未必要延續這個基礎?
- 假設將學校的目錄服務定義為2.16.886.111.123456.10,接下來的應用編碼可能是:
屬性類型(attribute types) --> 2.16.886.111.123456.10.1
物件類別(objectClass) --> 2.16.886.111.123456.10.2
自訂物件(cusObject) --> 2.16.886.111.123456.10.2.1
自訂人員(cusPerson) --> 2.16.886.111.123456.10.2.2
自訂群組(cusGroup) --> 2.16.886.111.123456.10.2.3 ...
本文原由作者本人於 2010-07-04 整理發表於 http://bod.tw/modules/tadnews/index.php?nsn=22
[LDAP入門]:建構LDAP的DIT
- 規劃LDAP最簡單的方式,是根據組織的現況,繪製組織圖,再將組織圖轉成Data Information Tree。
當然除了人員、部門已外,可能也會有將群組、應用程式、設備...等資料,納入LDAP管理的需求,這是ok的。
- LDAP的rootdn設定,是建立LDAP的起點,一般有兩種主要的命名方式:
(1) Geographic naming,例:suffix "o=組織名稱, c=國家名稱簡寫"
(2) Domain-based Naming,例:suffix "dc=組織名稱(簡稱), dc=網路域名"
以上是常見的規劃,當然不是只有這兩種形式可以選用,其他的形式,例:ou=部門名稱, o=組織名稱 ... 等
- 上述2的內容,再安裝LDAP server作基本設定的時候,就應該要想清楚、準備ok了,這裡只是重複說明一下。
- 接下來,也許會用 JXplorer / LDAPadmin,來建構資料的架構及內容。也可能會用LDIF(LDAP Database Interchange Format)檔案將準備好的資料,轉入LDAP,採用LDIF轉入資料,會是一個快速又有效的方法,CentOS有一個Migrationtools,提供了許多將Linux Users匯轉到LDAP的工具程式,程式所在位置: /usr/share/openldap/migration。
- 那 cn, o, ou, dc, c ...是什麼意思?詳細的說明,可以參閱 RFC 2253 LDAPv3 Distinguished Names 的內容說明。
dn: distinguished name
cn: common name
l: locality name
st: state or provinceName
o: organizationalName
ou: organizationalUnitName
c: countryName
street: streetAddress
dc: domain component
uid: user id
- LDAP的設計原則:
(1) 避免重新命名
(2) 不要修改標準的schema定義
(3) 選用適當的objectName
- 常用在組織或人員的objectClass:account / inetOrgPerson / organization / organizationalPerson / organizationalRole / organizationalUnit / person ...
參考資料:RFC 2798 Definition of the inetOrgPerson LDAP objectClass
本文原由作者本人於 2010-07-04 整理發表於 http://bod.tw/modules/tadnews/index.php?nsn=21
[LDAP入門]:資料的組成方式。資料模型(Information Model)。DIT : Data Information Tree
- LDAP的資料儲存方式為階層式,有別於目前常見的關聯式資料庫。
- 根路徑下的Entry,是儲存資料的位置,可以把這個樹狀圖想像成一張組織圖,每一個Entry可能是一個部門、人員。實際應用上,這也可能是一個應用程式、機器設備...等。
- 每個Entry,由一至數個ObjectClass所組成。
- objectClass間,可以繼承使用。
例:inetOrgPerson繼承自OrganizationalPerson,OrganizationalPerson繼承自Person,Person繼承自top,top是一個Abstract objectClass,是Entry個最上層物件。
- 每個objectClass由多個Attributes所組成。
[LDAP入門]:在CentOS下安裝OpenLDAP的基本步驟
- yum install openldap*
會安裝進去的軟體有: openldap_clients / openldap_devel / openldap_servers / openldap_servers_overlays
會安裝進去的其他相關軟體(Dependency):cyrus_sasl_devel / libtool_ltdl / unixODBC
- OpenLDAP資料存放的位置: /var/lib/ldap/ 目錄內
如果要重新設定LDAP server,先停止執行 ldap ( service ldap stop ),再移除資料目錄下的所有檔案 ( rm -Rf /var/lib/ldap/* )
- OpenLDAP相關設定檔的所在位置: /etc/openldap
- /etc/openldap/slapd.conf
設定目錄的根碼 suffix "dc=單位名稱,dc=單位網址" --> 一般有 Geographic / Domain-based 兩種命名的方式。
設定目錄的主管理者 rootdn "cn=Manager,dc=單位名稱,dc=單位網址" --> 這裡將主管理者命名為Manager
設定目錄主管理者的登入密碼 rootpw secret --> secrct是預設沒有經過加密編碼的密碼,可以視需求,選擇MD5或DES ...等加密方式,指定密碼。
- 將設定檔所在目錄位置下的/etc/openldap/DB_CONFIG.example,複製到資料存放的目錄下 /var/lib/ldap/DB_CONFIG
cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
- 建立目錄的根節點(root node) ,假設存放在 /etc/openldap/data/root.ldif,檔案內容如下:
dn: dc=單位名稱,dc=單位網址
objectClass: dcObject
objectClass: organization
o: 單位名稱說明
dc: 單位名稱
dn: cn=Manager, dc=單位名稱,dc=單位網址
objectClass: organinationalRole
cn: Manager
- 將目錄資料所在資料目錄的擁有者‧群組,指定為ldap, chown -Rf ldap:ldap /var/lib/ldap
- 將目錄根節點(root node)加到資料庫,slapadd -v -l /etc/openldap/data/root.ldif
- 啟動ldap /etc/rc.d/init.d/ldap start
- 使用ldapadmin / JXplorer 等軟體,瀏覽‧新增‧修改‧刪除資料 http://ldapadmin.sourceforge.net/
http://jxplorer.org/
- 參考資料:
http://www.openldap.org/
http://www.l-penguin.idv.tw/article/ldap-1.htm
http://xiangyang17.pixnet.net/blog/post/25051251
http://www.zytrax.com/books/ldap/
http://phpbuilder.com/manual/en/book.ldap.php
http://lena.franken.de/ldap/first_steps_in_ldap.html
訂閱:
文章 (Atom)










