LDAP 简单教程

LDAP 简单教程

LDAP(Lightweight Directory Access Protocol):轻量级目录访问协议。跟数据库同样均可以存放数据,可是跟数据库中存储形式不一样,LDAP中的数据是以树形结构组织的。以下图:html

DIT
          -----------------
          |dc=grouk,dc=com|
          -----------------
                  |可多个ou
             ----------
             |ou=users|  ...
             ----------
                  |
     -----------------------------
     |            |              |
-----------   -----------    -----------
|uid=user1|   |uid=user2|    |uid=user3|
-----------   -----------    -----------

LDAP 单位简称

  • c: country 国家
  • dc: domainComponent 域名
  • o: organization 组织 公司
  • ou: organizationUnit 部门
  • cn: common name 姓名
  • sn: suer name 姓

数据最小组织单元:Entry

Entry: DIT中最小的组织单元,相似关系数据表的一条记录。每一个entry的具体信息都以多个键值对的形式存储在entry中。这个键值对至关于关系数据表的字段与值。数据库

每一个entry有个惟一标示属性:dn。例如uid=user1节点的dn=uid=user1,ou=users,dc=grouk,dc=comapache

每一个entry必须至少包含一个objectClass属性,每种objectClass都规定了此objectClass必须包含哪些属性以及能够包含哪些属性。以下图:dom

sample_dn

例如 objectClass=person:工具

objectclass_person

LDAP Server: ApacheDS

  • ApacheDS: Java写的LDAP Server。
  • Apache Directory Studio: 管理ApacheDS数据的图形界面工具
  • 安装openldap-client包后,能够命令行方式操做LDAP Server的数据
    • ldapadd
    • ldapdelete
    • ldapsearch

查询entry为uid=user2的详细信息:ui

  • -D: 绑定dn
  • -w: 绑定dn的密码
  • -b: base dn for search
  • -s: 搜索空间,搜索条件可有有与或非操做
  • +: 请求server返回全部操做属性
ldapsearch -h localhost -p 10389 -D "uid=user2,ou=users,dc=groukTest,dc=com" -w "user2" -b "dc=groukTest,dc=com" -s sub "(cn=user1)" +
# extended LDIF
#
# LDAPv3
# base <dc=groukTest,dc=com> with scope subtree
# filter: (cn=user1)
# requesting: + 
#

# user1, testUser, groukTest.com
dn: uid=user1,ou=testUser,dc=groukTest,dc=com
entryCSN: 20151207101413.644000Z#000000#001#000000
creatorsName: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
modifyTimestamp: 20151203081101.820Z
entryDN: uid=user1,ou=testUser,dc=groukTest,dc=com
modifiersName: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
entryUUID: c62b65ef-52fc-444b-be2d-2d3b7d04acdf
createTimestamp: 20151203044532.269Z
pwdFailureTime: 20151207101351.817Z
pwdFailureTime: 20151207101413.644Z
entryParentId: 8012db2c-73cd-4c8f-830b-7229e948dd28

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

Password Policy

ApacheDS默认启用密码策略,建议修改DN: ads-pwdid=default,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryserviceid=default,ou=config的ads-pwdlockoutduration属性值为非0。默认为0,即用户连续输错指定次数密码后,此用户被永久禁用。this

pwdLockoutDuration: this attribute holds the number of seconds that the password cannot be used to authenticate due to too many failed bind attempts. If this attribute is not present, or if the value is 0 the password cannot be used to authenticate until reset by a password administrator.命令行

遇到的问题

用户输错必定次数的密码后,用户被永久禁用。在网上搜了下没有找到解决办法,后来看到了这个文档:Password Policy for LDAP Directories draft-behera-ldap-password-policy-10.txtpwdAccountLockedTimepwdLockoutDuration两个属性的说明得以解决。code

解决方法:server

相关文章
相关标签/搜索