LDAP-ObjectClass
LDAP中,一条记录必须包含一个objectClass属性,且其需要赋予至少一个值。每一个值将用作一条LDAP记录进行数据存储的模板;模板中包含了一条记录中数个必须被赋值的属性和一系列可选的属性。
objectClass有着严格的等级之分,最顶层的类是top和alias。例如,organizationalPerson这个objectClass隶属于Person,而Person又是top的子类。
objectClass大致分为三类:结构型的(如:person和organizationUnit)、辅助型的(如:extensibeObject)和抽象型的(这类不能直接使用)。官方定义的objectClass,如下所示:
alias
applicationEntity
dSA
applicationProcess
bootableDevice
certificationAuthority
certificationAuthority-V2
country
cRLDistributionPoint
dcObject
device
dmd
domain
domainNameForm
extensibleObject
groupOfNames
groupOfUniqueNames
ieee802Device
ipHost
ipNetwork
ipProtocol
ipService
locality
dcLocalityNameForm
nisMap
nisNetgroup
nisObject
oncRpc
organization
dcOrganizationNameForm
organizationalRole
organizationalUnit
dcOrganizationalUnitNameForm
person
organizationalPerson
inetOrgPerson
uidOrganizationalPersonNameForm
residentialPerson
posixAccount
posixGroup
shadowAccount
strongAuthenticationUser
uidObject
userSecurityInformation
使用LDAP做身份验证
objectClass中的person可以用来作linux系统中用户登入的身份验正,此时需要指定userPassword属性的值,即指定用户登入时使用的密码。密码可以使用的加密方式有MD5、CRYPT、SHA、SSHA等。在LDAP V3中,验正客户端时可以使用的验正机制有匿名验正、简单验正、基于SSL/TLS的验正和基于SASL的验正等四种方式。
OPENLDAP配置文件
接下来我们对上述部分进行一些介绍:
include /etc/openldap/openldap/schema/core.schema
此句是用来将目录所用到的schema文件包含进来;openldap一般默认带有几个schema,在我们的配置文件安装目录下的schema目录中存放。本句中的core.schema是LDAP V3中必须的,它给出了LDAP V3中最基本的attribute和objects的定义。其它的还有:corba.schema、dyngroup.schema、java.schema nis.schema、openldap.schema、cosine.schema、inetorgperson.schema、misc.schema、ppolicy.schema
pidfile /usr/local/openldap/var/run/slapd.pid
此句用来定义slapd进程运行时的pid文件,需要使用绝对路径。
argsfile /usr/local/openldap/var/run/slapd.args
此句用来定义包含当前正在运行的slapd进程所用到的命令行参数的文件,需要使用绝对路径。
# Load dynamic backend modules:
# modulepath /usr/local/openldap/libexec/openldap
# moduleload back_bdb.la
# moduleload back_ldap.la
# moduleload back_ldbm.la
# moduleload back_passwd.la
# moduleload back_shell.la
以上用来指定动态加载的后端模块。
以上是安全相关的声明语句。常用到的参数有五类,除了Require和security外还有Allow、Disallow和password-hash等。
Require参数用来使管理员指定访问目录时必须遵循的规则和条件;这种指定可以是全局的,也可以仅用来限制对某个后端数据库的访问限制。
security参数用来让管理员指定加强安全性的一般规则。
# Sample access control policy:
# Root DSE: allow anyone to read it
# Subschema (sub)entry DSE: allow anyone to read it
# Other DSEs:
# Allow self write access
# Allow authenticated users read access
# Allow anonymous users to authenticate
# Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
# by self write
# by users read
# by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn. (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!
#ACL configure 以下内容定义访问控制
access to attr=userPassword userPassword只能由自已修改,有效验证用户查询。
by self write
by anonymous auth
access to attr=mail
by dn="cn=root,dc=it,dc=tigerhead" write mail只能由自已修改,有效验证用户查询。
by self write
by anonymous auth
access to dn=".*,dc=it,dc=tigerhead" 允许所有人查询没受控制访问限制的信息。
by self write
by * read