`
chilongxph
  • 浏览: 135785 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

LDAP学习2

阅读更多
Sun Directory Server/LDAP学习笔记(二) -摘录2009-07-22 22:57Java6.0 API for LDAP概述

从JDK5.0开始,对LDAP协议的数据访问操作就被集成在javax的扩展API包中,并随同JDK一并发布,这一章节,我们主要介绍API包中的类信息。
javax.naming.directory 包的结构


常用API解析

javax.naming.directory.InitialDirContext,初始化目录服务上下文类
该类是LDAP数据内容的操作工具类,通过该类可以执行绑定LDAP服务器、新增LDAP条目、获取条目实例、修改条目属性、删除条目和根据条件搜索条目等操作。常用方法说明如下:

初始化LDAP 目录服务上下文(相当于使用JDBC打开一个数据库链接)
InitialDirContext(Hashtable<?,?> environment)

绑定/创建LDAP条目对象(相当于新增一个LDAP条目数据bind(Name
name, Object obj, Attributes attrs)
bind(String name, Object obj, Attributes attrs)
createSubcontext(Name name, Attributes attrs)
createSubcontext(String name, Attributes attrs)

获取条目实例(属性集)

getAttributes(Name name)
getAttributes(Name name, String[] attrIds)
getAttributes(String name)
getAttributes(String name, String[] attrIds)

修改条目属性

modifyAttributes(Name name, int mod_op, Attributes attrs)
modifyAttributes(Name name, ModificationItem[] mods)
modifyAttributes(String name, int mod_op, Attributes attrs)
modifyAttributes(String name, ModificationItem[] mods)

删除条目

destroySubcontext(Name name)
destroySubcontext(String name)

根据属性集搜索条目

search(Name name, Attributes matchingAttributes)
search(Name name, Attributes matchingAttributes, String[] attributesToReturn)
search(String name, Attributes matchingAttributes)
search(String name, Attributes matchingAttributes, String[] attributesToReturn)

根据过滤器搜索条目

search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons)
search(Name name, String filter, SearchControls cons)
search(String name, String filterExpr, Object[] filterArgs, SearchControls cons)
search(String name, String filter, SearchControls cons)


javax.naming.directory.BasicAttribute,LDAP基本属性对象
该类用来表示LDAP条目中的单个属性对象。在目录服务中,每个属性名称是可以对应多个的属性值的。

构建属性对象

BasicAttribute(String id)
BasicAttribute(String id, boolean ordered)
BasicAttribute(String id, Object value)
BasicAttribute(String id, Object value, boolean ordered)

添加属性值

add(int ix, Object attrVal),添加属性值到多值属性的指定位置
add(Object attrVal) , 追加属性值到多值属性尾部

判断属性值是否包含

contains(Object attrVal) , 多值属性中有一个值是匹配的,返回true

获取属性值

get(),取得属性值中的一个
get(int ix),从多值属性中的指定位置取值

获取属性ID

getID(),属性的ID就是属性名

删除属性值

remove(int ix),删除指定位置的属性值
remove(Object attrval),删除指定的属性值


javax.naming.directory.BasicAttributes,LDAP实体的属性集
该类表示一个LDAP条目绑定的属性集合,在绝大多数情况下,一个LDAP条目存在多个属性。

构造属性集

BasicAttributes()
BasicAttributes(boolean ignoreCase),属性ID是否大小写敏感,建议不要使用敏感
BasicAttributes(String attrID, Object val)
BasicAttributes(String attrID, Object val, boolean ignoreCase)

获取属性集中的单个属性对象

get(String attrID)

获取全部属性的枚举

getAll()

获取全部属性的ID枚举

getIDs()

添加新属性

put(Attribute attr)
put(String attrID, Object val)

移除指定属性

remove(String attrID)


javax.naming.directory.SearchControls , LDAP目录服务搜索控制对象
该类负责控制LDAP搜索行为的范围、设定返回结果数上限,搜索耗时上限,指定结果所包括的属性集等。

设定搜索行为的范围

setSearchScope(int scope)

设定返回结果数上限

setCountLimit(long limit)

设定搜索耗时上限

setTimeLimit(int ms) , 以毫秒为单位

指定结果所包括的属性集

setReturningAttributes(String[] attrs)


javax.naming.directory.SearchResult , 表示.search() 方法的返回结果集中的一项。
SearchResult类是对LDAP条目属性集的封装。在search()操作中可能返回完整的条目属性,也可能是条目属性的一部分。

获取SearchResult封装的条目属性

getAttributes()


文章来源:http://hi.baidu.com/millionware/blog/
分享到:
评论

相关推荐

    LDAP中文学习手册

    ldap学习手册,自己之前网上下载的,现在拿出来供大家分享

    LDAP学习笔记相关资料

    LDAP学习笔记,包含LDAP基础知识,以及一些技巧和思考

    ldap学习文档

    ldap学习

    关于ldap学习资料,感兴趣的看看,ldap5.2管理手册.pdf

    关于ldap学习资料,感兴趣的看看,ldap5.2管理手册.pdf

    Ldap学习手册pdf版

    Ldap学习手册,英文高清晰pdf版,有需要的请收藏

    LDAP中文学习手册.pdf

    LDAP 是轻量级目录访问协议的简称(Lightweight Directory Access Protocol).用于访问目录服务。 它是 X.500 目录访问协议的移植,但是简化了实现方法。

    LDAP学习资料

    LDAP学习资料,里面含有ldap的增、删、改、查操作,是基于spring的。

    LDAP中文学习手册.doc

    LDAP中文学习手册.doc

    对LDAP的基本操作(Spring-ldap)+Ext实现显示LDAP的树状结构

    由于这些我也是才入门的时候写的,进行测试等用的,所以比较适合新手,对学习LDAP,extjs会有一定的帮助。 (需要改正的是extjs里那个节点的id要加上前面的id才行,比如ou=mail; 那它的子节点cn=wang的id应该是...

    LDAP技术,LDAP学习大全

    LDAP 技术总结 第一章LDAP 有关技术介绍......................................................................................................... 3 第一节X.500 目录服务......................................

    LDAP服务器.pdf

    http://www.mirapoint.com Page 145 of 170 第一八章 LDAP 服务器 学习目标: 了解 LDAP 服务器的相关知识。学会配置 Mirapoint Directory 目录服务器。 1 LDAP 基础 LDAP 的英文全称是 Lightweight Directory ...

    很好的LDAP学习资料

    很好的LDAP学习资料,几乎涉及到LDAP的所有基本概念,非常适合入门者参考学习。也是管理员必看的参考资料。

    ldap openldap

    openldap安装配置 java操作ldap

    java连接和验证ldap文档

    java连接和验证的ldap学习文档,密码的校验,通过jndi连接ldap服务

    LDAP详解,初学习者可以看看

    学习ldap的资料,就是有点老了,可以看看

    LDAP统一身份认证

    此包包含: LDAP的研究及其在统一身份认证系统中的应用 LDAP的研究与在校园网统一身份认证中的应用 基于LDAP的统一身份认证的设计与实现 ...当然,里面有很多很好的技术和开发思想,你也可以学习下。

    [原创]学习LDAP笔记

    自己学习LDAP的笔记记录,包括有LDAP的简单介绍,在windows下的安装部署及api介绍,Linux下的编译安装及在KDevelop下的api调用。还有对一个可视化管理工具phpLDAPadmin的介绍

    ldap入门学习资料

    ldap入门学习资料,是公司内部发放的,还不错。

    ldap 学习指南

    ldap 学习指南,60大洋买的,学习下,很不错,希望支持。

Global site tag (gtag.js) - Google Analytics