$ slappasswd New password: Re-enter new password: {SSHA}z/rsbmAjVtLlWeUB0xS5itLPI0VA1akD
$ vim chdomain.ldif # replace to your own domain name for "dc=***,dc=***" section # specify the password generated above for "olcRootPW" section 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=admin,dc=leeif,dc=me"read by * none
第五步,在上述基础上,我们来创建一个叫做 leeif News Agency 的组织,并在其下创建一个 Manager 的组织角色(该角色内的用户具有管理整个 LDAP 的权限)和 People 和 Group 两个组织单元:
$ vim basedomain.ldif # replace to your own domain name for "dc=***,dc=***" section dn: dc=leeif,dc=me objectClass: top objectClass: dcObject objectclass: organization o: leeif.IO dc: leeif
接下来,我们来创建一个叫作 Ada Catherine 的员工并将其分配到 Secretary 组来验证上述配置是否生效。
$ slappasswd New password: Re-enter new password: {SSHA}HTGqAd4p6fOOIVHm7VZYUSorWGfnrqAA
$ vim ldapuser.ldif # create new # replace to your own domain name for "dc=***,dc=***" section dn: uid=ada,ou=people,dc=leeif,dc=me objectClass: inetOrgPerson objectClass: posixAccount objectClass: shadowAccount uid: ada cn: Ada Catherine sn: Catherine userPassword: {SSHA}HTGqAd4p6fOOIVHm7VZYUSorWGfnrqAA loginShell: /bin/bash uidNumber: 1000 gidNumber: 1000 homeDirectory: /home/users/ada
dn: cn=Secretary,ou=group,dc=leeif,dc=me objectClass: posixGroup cn: Secretary gidNumber: 1000 memberUid: ada
# ldapadd -x -D cn=admin,dc=leeif,dc=me -W -f ldapuser.ldif Enter LDAP Password: adding new entry "uid=ada,ou=People,dc=leeif,dc=org" adding new entry "cn=Secretary,ou=Group,dc=leeif,dc=org"
我们也可以使用 ldapsearch 命令来查看 LDAP 目录服务中的所有条目信息:
$ ldapsearch -x -b "dc=leeif,dc=me" -H ldap://127.0.0.1 # extended LDIF # # LDAPv3 # base <dc=leeif,dc=me> with scope subtree # filter: (objectclass=*) # requesting: ALL #
include /etc/openldap/schema/core.schema include /etc/openldap/schema/collective.schema include /etc/openldap/schema/corba.schema include /etc/openldap/schema/cosine.schema include /etc/openldap/schema/duaconf.schema include /etc/openldap/schema/dyngroup.schema include /etc/openldap/schema/inetorgperson.schema include /etc/openldap/schema/java.schema include /etc/openldap/schema/misc.schema include /etc/openldap/schema/nis.schema include /etc/openldap/schema/openldap.schema include /etc/openldap/schema/pmi.schema include /etc/openldap/schema/ppolicy.schema