日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

ldap导入mysql_openLDAP 部署(亲测可用)

發布時間:2024/9/19 数据库 54 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ldap导入mysql_openLDAP 部署(亲测可用) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前言

最近在搭建openLDAP時候百度了挺多文章,大多都缺失一部分,或者進行不下去。個人整理出文章供大家參考 ,如有錯誤請指出。

介紹

輕型目錄訪問協議(簡稱LDAP)是一種行業標準的輕量級協議,廣泛用于訪問目錄服務。目錄服務是一種共享的信息基礎結構,用于訪問,管理,組織和更新日常項目和網絡資源,例如用戶,組,設備,電子郵件地址,電話號碼,容量和許多其他對象。

該LDAP信息模型是基于條目。LDAP目錄中的條目代表單個單位或信息,并由所謂的專有名稱(DN)唯一標識。每個條目的屬性都有一個類型和一個或多個值。

屬性是與條目關聯的一條信息。這些類型通常是助記符字符串,例如,“ cn ”代表通用名稱,“ mail ”代表電子郵件地址。為每個屬性分配一個或多個值,這些值由空格分隔的列表組成。

以下說明了如何在LDAP目錄中安排信息。

Ldap信息模型

在本文中,我們將展示如何在CentOS 7中安裝和配置OpenLDAP服務器以進行集中身份驗證。

安裝

環境介紹

CentOS 7.6

關閉防火墻

ldap版本2.4.xx

1.首先,首先使用以下命令安裝OpenLDAP,這是LDAP的開源實現和一些傳統的LDAP管理實用程序。

#yum -y install openldap compat-openldap openldap-clients openldap-servers openldap-devel

2.在CentOS 7上,運行以下命令以啟動openldap服務器守護程序,使其在啟動時自動啟動,并檢查其是否啟動并運行

# systemctl start slapd

# systemctl enable slapd

# systemctl status slapd

# slapd -VV

配置ldap server

注意:不建議手動編輯LDAP配置,您需要將配置添加到文件中,并使用ldapadd或ldapmodify命令將它們加載到LDAP目錄中,如下所示。

現在創建一個OpenLDAP管理用戶,并為該用戶分配密碼。在以下命令中,將為給定密碼創建一個哈希值,請注意該哈希值,您將在LDAP配置文件中使用它。

# slappasswd

然后創建一個LDIF文件(ldaprootpasswd.ldif),該文件用于將條目添加到LDAP目錄。

# vim ldaprootpasswd.ldif

dn: olcDatabase={0}config,cn=config

changetype: modify

add: olcRootPW

olcRootPW: {SSHA}PASSWORD_CREATED

explaining the attribute-value pairs above:

olcDatabase: indicates a specific database instance name and can be typically found inside /etc/openldap/slapd.d/cn=config.

cn=config: indicates global config options.

PASSWORD: is the hashed string obtained while creating the administrative user.

3.接下來,通過指定引用ldap服務器和上面文件的URI添加相應的LDAP條目。

# ldapadd -Y EXTERNAL -H ldapi:/// -f ldaprootpasswd.ldif

配置 LDAP 數據

1.現在,將用于slapd的示例數據庫配置文件復制到/ var / lib / ldap目錄中,并對該文件設置正確的權限。

# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

# chown -R ldap:ldap /var/lib/ldap/DB_CONFIG

# systemctl restart slapd

2.接下來,如下所示從/ etc / openldap / schema目錄中導入一些基本LDAP模式。

# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif

# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif

# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif

3.現在,將您的域添加到LDAP數據庫中,并為您的域創建一個名為ldapdomain.ldif的文件。

# vim ldapdomain.ldif

在其中添加以下內容(將示例替換為您的域,并將PASSWORD替換為之前獲得的哈希值)

dn: olcDatabase={1}monitor,cn=config

changetype: modify

replace: olcAccess

olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"

read by dn.base="cn=Manager,dc=example,dc=com" read by * none

dn: olcDatabase={2}hdb,cn=config

changetype: modify

replace: olcSuffix

olcSuffix: dc=example,dc=com

dn: olcDatabase={2}hdb,cn=config

changetype: modify

replace: olcRootDN

olcRootDN: cn=Manager,dc=example,dc=com

dn: olcDatabase={2}hdb,cn=config

changetype: modify

add: olcRootPW

olcRootPW: {SSHA}PASSWORD

dn: olcDatabase={2}hdb,cn=config

changetype: modify

add: olcAccess

olcAccess: {0}to attrs=userPassword,shadowLastChange by

dn="cn=Manager,dc=example,dc=com" write by anonymous auth by self write by * none

olcAccess: {1}to dn.base="" by * read

olcAccess: {2}to * by dn="cn=Manager,dc=example,dc=com" write by * read

4.然后使用以下命令將上述配置添加到LDAP數據庫中

# ldapmodify -Y EXTERNAL -H ldapi:/// -f ldapdomain.ldif

5.在這一步中,我們需要向LDAP目錄中添加一些條目。使用以下內容創建另一個名為baseldapdomain.ldif的文件。

dn: dc=example,dc=com

objectClass: top

objectClass: dcObject

objectclass: organization

o: example com

dc: example

dn: cn=Manager,dc=example,dc=com

objectClass: organizationalRole

cn: Manager

description: Directory Manager

dn: ou=People,dc=example,dc=com

objectClass: organizationalUnit

ou: People

dn: ou=Group,dc=example,dc=com

objectClass: organizationalUnit

ou: Group

Save the file and then add the entries to the LDAP directory.

# ldapadd -Y EXTERNAL -x -D cn=Manager,dc=example,dc=com -W -f baseldapdomain.ldif

6.下一步是創建LDAP用戶(例如tecmint),并為該用戶設置密碼,如下所示。

# useradd tecmint

# passwd tecmint

7.然后在具有以下內容的名為ldapgroup.ldif的文件中為LDAP組創建定義。

dn: cn=Manager,ou=Group,dc=example,dc=com

objectClass: top

objectClass: posixGroup

gidNumber: 1005

在以上配置中,gidNumber是/ etc / group中tecmint的GID,并將其添加到OpenLDAP目錄中。

# ldapadd -Y EXTERNAL -x -W -D "cn=Manager,dc=example,dc=com" -f ldapgroup.ldif

8.接下來,創建另一個名為ldapuser.ldif的LDIF文件,并添加用戶tecmint的定義。

dn: uid=tecmint,ou=People,dc=example,dc=com

objectClass: top

objectClass: account

objectClass: posixAccount

objectClass: shadowAccount

cn: tecmint

uid: tecmint

uidNumber: 1005

gidNumber: 1005

homeDirectory: /home/tecmint

userPassword: {SSHA}PASSWORD_HERE

loginShell: /bin/bash

gecos: tecmint

shadowLastChange: 0

shadowMax: 0

shadowWarning: 0

然后將配置加載到LDAP目錄。

# ldapadd -Y EXTERNAL -x -D cn=Manager,dc=example,dc=com -W -f ldapuser.ldif

一旦設置了用于身份驗證的中央服務器,最后一部分就是使客戶端能夠使用LDAP進行身份驗證,可以使用phpldapadmin或ldapadmin.exe(推薦)

有關更多信息,請參閱《OpenLDAP軟件》文檔目錄中的相應文檔

總結

以上是生活随笔為你收集整理的ldap导入mysql_openLDAP 部署(亲测可用)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。