则通过“组”进行控制。
二、用户需求
1. 用户结构:
YourComp
|- groups (departments)
| |- grp1 (dep1)
| | |- user1
| | - user2
| |- grp2 (dep2)
| | |- user3
| | - user4
| - grp3 (dep3)
| |- user2
| - user3
- members (employees)
|- user1
|- user2
|- user3
- user4
2. 目录权限:
AppsDir
|- Dir1 允许 grp1 访问
|- Dir2 允许 grp2 访问
- Dir3 允许 grp1, grp3 访问
三、配置步骤
1. 建立 LDAP 基础记录,BaseDn.ldif 文件: dn: dc=YourComp
dc: YourComp
objectClass: domain dn: ou=members,dc=YourComp
ou: members
objectClass: organizationalUnit dn: ou=groups,dc=YourComp
ou: groups
objectClass: organizationalUnit
2. 建立 LDAP 用户记录,UserDn.ldif 文件: dn:cn=user1,ou=members,dc=YourComp
cn: user1
sn: USER1
uid: user1
userPassword: user1
objectClass: inetOrgPerson dn:cn=user2,ou=members,dc=YourComp
cn: user2
sn: USER2
uid: user2
userPassword: user2
objectClass: inetOrgPerson dn:cn=user3,ou=members,dc=YourComp
cn: user3
sn: USER3
uid: user3
userPassword: user3
objectClass: inetOrgPerson dn:cn=user4,ou=members,dc=YourComp
cn: user4
sn: USER4
uid: user4
userPassword: user4
objectClass: inetOrgPerson
3. 建立 LDAP 用户组记录,GroupDn.ldif 文件: dn: cn=grp1,ou=groups,dc=YourComp
cn: grp1
objectClass: groupOfUniqueNames
objectClass: top
uniqueMember: cn=user1,ou=members,dc=YourComp
uniqueMember: cn=user2,ou=members,dc=YourComp dn: cn=grp2,ou=groups,dc=YourComp
cn: grp2
objectClass: groupOfUniqueNames
objectClass: top
uniqueMember: cn=user3,ou=members,dc=YourComp
uniqueMember: cn=user4,ou=members,dc=YourComp dn: cn=grp3,ou=groups,dc=YourComp
cn: grp3
objectClass: groupOfUniqueNames
objectClass: top
uniqueMember: cn=user3,ou=members,dc=YourComp
uniqueMember: cn=user2,ou=members,dc=YourComp
4. 运行 ldapadd 添加记录
添加根记录:
ldapadd -x -D "cn=root,dc=YourComp" -w secret -f BaseDn.ldif
添加用户记录:
ldapadd -x -D "cn=root,dc=YourComp" -w secret -f UserDn.ldif
添加用户组记录:
ldapadd -x -D "cn=root,dc=YourComp" -w secret -f GroupDn.ldif
5. 建立 Apache 配置文件,application_auth.conf: <Location /AppsDir>;
AuthType Basic
AuthName "Please login" AuthLDAPEnabled on
AuthLDAPAuthoritative on
AuthLDAPURL "=*)"
</Location>; <Location /AppsDir/dir1>;
require group cn=grp1,dc=YourComp
</Location>; <Location /AppsDir/dir2>;
require group cn=grp2,dc=YourComp
</Location>; <Location /AppsDir/dir3>;
require group cn=grp1,dc=YourComp cn=grp3,dc=YourComp
</Location>;
6. 在 httpd.conf 文件中,加入以下行: include conf/application_auth.conf
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。