UOS configure LDAP

  • Install openldap to provide account authentication for the apacheQ service;
  • Create the chinaskills.cn directory service, create the user group ldsgp, and add zsuser, lsusr, wuusr

1. Installation services

[root@Server04 /]# apt install slapd  ldap-utils -y
#设置slapd的密码

d5663c6bd9842bb0c8382eee5bab9791.png

2. Modify the configuration file

[root@Server04 /]# nano /etc/ldap/ldap.conf  
BASE    dc=chinaskills,dc=cn
URI     192.168.10.4 192.168.10.4:389

3. Update ldap information

[root@Server04 /]# dpkg-reconfigure slapd

9145c2e2f9529a04cd66b371f35268fe.png

74e5b921e792977af6782b885202c0d5.png

31d9647951b11e46eeb7ca1c9a6f45b6.png

3ed7dc687a1eef44f7d79ce3159d28ca.png

aaafad0afc434b3f21ef2000d19a3e20.png

 

df1051c647be6b219a262554a7b1a557.png

49c54a8b8c7f72631e1aa0077ed27959.png

4. Test whether the installation is complete

[root@Server04 /]# ldapsearch -x    
# extended LDIF
#
# LDAPv3
# base <dc=chinaskills,dc=cn> (default) with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#
# chinaskills.cn
dn: dc=chinaskills,dc=cn
objectClass: top
objectClass: dcObject
objectClass: organization
o: chinaskills
dc: chinaskills
# admin, chinaskills.cn
dn: cn=admin,dc=chinaskills,dc=cn
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
# search result
search: 2
result: 0 Success
# numResponses: 3
# numEntries: 2

5. Create user groups and users

[root@Server04 /]# cd /etc/ldap/    #进入ldap目录
[root@Server04 /etc/ldap]# vim group.ldif  #新建文件group.ldif 后缀格式一定要对
dn: ou=users,dc=chinaskills,dc=cn
objectclass: organizationalUnit
ou: users
dn: ou=ldsgp,dc=chinaskills,dc=cn
objectclass :organizationalUnit
ou: group

[root@Server04 /etc/ldap]# nano zsuser.ldif
dn: uid=zsuser,ou=users,dc=chinaskills,dc=cn
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
uid: zsuser
cn: zsuser
userPassword: ChinaSkill22
shadowLastChange: 0
shadowMax: 0
shadowWarning: 0
loginShell: /bin/bash
uidNumber: 1008
gidNumber: 1008
homeDirectory: /home/zsuser
gecos: zsuser

[root@Server04 /etc/ldap]# ldapadd -x -D "cn=admin,dc=chinaskills,dc=cn" -W  -f zsuser.ldif 
Enter LDAP Password: 
adding new entry "uid=zsuser,ou=users,dc=chinaskills,dc=cn"

6. Add users to groups

[root@Server04 /etc/ldap]#  nano jr.ldif
dn: cn=jr,ou=ldsgp,dc=chinaskills,dc=cn
objectclass: posixGroup
gidNumber: 10001
cn: jr 
memberUid: zsuser

[root@Server04 /etc/ldap]# ldapadd -x -D "cn=admin,dc=chinaskills,dc=cn" -W  -f jr.ldif 
Enter LDAP Password: 
adding new entry "cn=jr,ou=ldsgp,dc=chinaskills,dc=cn"

7. Test

[root@Server04 /etc/ldap]# ldapsearch -x -LLL | grep 'dn: dc'
dn: dc=chinaskills,dc=cn
root@Server04:/etc/ldap# ldapsearch -x -LLL | grep 'dn: uid'
dn: uid=zsuser,ou=users,dc=chinaskills,dc=cn

 

 

Guess you like

Origin blog.csdn.net/LLLLLoodwd/article/details/131325598
Recommended