LDAP是一个轻量级目录管理系统。可以统一管理账号。对数据的读取速度快,存储数据的能力慢。 LADP有server和client端。 安装环境: ldap server和 ldap client分别安装在两台ubuntu14.04上(虚拟机上)。

一:ldap服务机的搭建,配置            1:ldap server安装:                    1.1: sudo apt-get install slapd ldap-utils                    1.2: 安装过程中会提示输入LDAP管理密码:test123456(以这个密码列)。                    通过1.1和1.2之后,安装ldap server安装,但是ldap server没有完全配置,我们需执行下面命令来完成其他的配置。                             1.3:sudo dpkg-reconfigure slapd                    1.4:根据提示消息完成配置。推荐如下: NO , test.com , china ,tset123456,tset123456,HDB  ,NO,YES,NO                    1.5:验证安装是否正常:ldapsearch -x -LLL -b dc=test,dc=com 以及 netstat -an | grep 389                      yaolan@TestSer:~$                      yaolan@TestSer:~$ ldapsearch -x -LLL -b dc=test,dc=com                      dn: dc=test,dc=com                      objectClass: top                      objectClass: dcObject                      objectClass: organization                      o: china                      dc: test                     dn: cn=admin,dc=test,dc=com                     objectClass: simpleSecurityObject                     objectClass: organizationalRole                     cn: admin                     description: LDAP administrator                                       2:在安装ldap server后,如何添加用户等                       2.1: 通过ldapadd命令添加*.ldif文件。                               ldapadd -x -D "cn=admin,dc=test,dc=com" -W -f test.ldif                               结果如下:                               yaolan@TestSer:~$ ldapadd -x -D "cn=admin,dc=test,dc=com" -W -f test.ldif                               Enter LDAP Password:                               adding new entry "ou=Groups,dc=test,dc=com"                               adding new entry "cn=User,ou=Groups,dc=test,dc=com"                               adding new entry "ou=Users,dc=test,dc=com"                               可以通过ldapsearch -x -D "cn=admin,dc=huawei,dc=com"来查看结果。                                以下是test.ldif文件内容:添加了User组                                 yaolan@TestSer:~$                                 yaolan@TestSer:~$ cat test.ldif                                 dn: ou=Groups,dc=test,dc=com                                 objectClass: organizationalUnit                                 ou: Groups                                 dn: cn=User,ou=Groups,dc=test,dc=com                                 objectClass: posixGroup                                 cn: User                                 gidNumber: 10002                                 description: Group account                                dn: ou=Users,dc=test,dc=com                                ou: Users                                objectClass: top                                objectClass: organizationalUnit                                            2.2也可以通过ldapscripts来管理。                                   sudo apt-get install ldapscripts                           2.2.1:修改 sudo vim /etc/ldapscripts/ldapscripts.conf 如下:                                     SERVER=localhost                                     SUFFIX="dc=test,dc=com"                                     GSUFFIX="ou=Groups"                                     USUFFIX="ou=Users"                                     BINDDN="cn=admin,dc=test,dc=com"                                     BINDPWDFILE="/etc/ldapscripts/ldapscripts.passwd"                            2.2.2: 修改 sudo vim /etc/ldapscripts/ldapscripts.passwd 如下:                                    echo -n "test123456" > /etc/ldapscripts/ldapscripts.passwd                             之后就可以使用ldapadduser和ldapaddgoup 等命令了。

              3: 修改  /etc/nsswitch.conf 如下:                                passwd: files ldap                                group: files ldap                                shadow: files ldap                           添加这行到/etc/pam.d/common-account末尾:  session required pam_mkhomedir.so skel=/etc/skel/ umask=0022        二:在另一台pc安装ldap client                    1:安装 sudo apt-get install libpam-ldap nscd                          安装提示修改配置:                     2. 如果有需要修改ldap client配置                          sudo apt-get install ldap-auth-config  或者   sudo dpkg-reconfigure ldap-auth-config[2]                     3.修改其他配置                         修改  /etc/nsswitch.conf 如下:                                passwd: files ldap                                group: files ldap                                shadow: files ldap                          添加这行到/etc/pam.d/common-account末尾:  session required pam_mkhomedir.so skel=/etc/skel/ umask=0022                       4.重启服务: sudo service nscd restart

Reference: [1] https://www.digitalocean.com/community/tutorials/how-to-authenticate-client-computers-using-ldap-on-an-ubuntu-12-04-vps [2] http://www.debian-administration.org/article/403/Giving_users_a_home_directory_automatically [3] http://blog.csdn.net/scarecrow_byr/article/details/42471461


本文来自 cradle08 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/u011774239/article/details/51258685?utm_source=copy