2. LDAP客户端安装与配置
2.1 使用apt-get安装相关服务
#sudo apt-get install libnss-ldapd libpam-ldapd
安装过程中根据安装向导输入ldap服务器IP和相应base域名信息,最后,针对nss services勾选group和passwd两项即可。
注:Ubuntu系统中LDAP客户端的配置文件为/etc/nslcd.conf和/etc/nsswitch.conf,以上配置信息都可以在该配置文件中随时修改!修改后要重启服务:service nslcd restart
# /etc/nslcd.conf
# nslcd configuration file. See nslcd.conf(5)
# for details.
# The user and group nslcd should run as.
uid nslcd
gid nslcd
# The location at which the LDAP server(s) should be reachable.
uri ldap://127.0.0.1/
# The search base that will be used for all queries.
base dc=edu,dc=example,dc=org
# The LDAP protocol version to use.
#ldap_version 3
# The DN to bind with for normal lookups.
#binddn cn=annonymous,dc=example,dc=net
#bindpw secret
# SSL options
#ssl off
#tls_reqcert never
# The search scope.
#scope sub
# nslcd configuration file. See nslcd.conf(5)
# for details.
# The user and group nslcd should run as.
uid nslcd
gid nslcd
# The location at which the LDAP server(s) should be reachable.
uri ldap://127.0.0.1/
# The search base that will be used for all queries.
base dc=edu,dc=example,dc=org
# The LDAP protocol version to use.
#ldap_version 3
# The DN to bind with for normal lookups.
#binddn cn=annonymous,dc=example,dc=net
#bindpw secret
# SSL options
#ssl off
#tls_reqcert never
# The search scope.
#scope sub
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat ldap
group: compat ldap
shadow: compat
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat ldap
group: compat ldap
shadow: compat
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
2.2 安装配置完成后,使用以下命令验证访问LDAP服务器是否成功
#getent passwd
#getent group
若不能正确显示LDAP服务器上的相关用户和组,则检查以下原因:
①LDAP服务器是否开启
②LDAP服务器防火墙是否关闭
③客户端配置的LDAP服务器IP是否正确,可否ping通
④客户端配置的base域名是否正确
⑤端口不对
⑥版本不对
-----------------------------------------------
-----------------------------------------------
【相关说明】
① libnss-ldap 被用于名字解析, libpam-ldap 用 pm 通过LDAP来认证用户。
更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2
