java对Ldap操作1
2008-02-22 14:47
357 查看
前一阵学习了ldap,用java小试了一下,只实现java对ldap的查找、登陆功能,传上来供初级学者参考:
UserDaoLdap:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package ldap;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import java.util.List;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import ldap.pojo.LdapPersonInfo;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* access Ldap
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @author 张亮
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public interface UserDaoLdap ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 获得所有的用户名(ldap称cn),可根据第二个参数指定返回值是否重复
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param distinct
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* true,去掉结构中的重复值;false 允许结果中包含重复值
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 查询范围下返回的cn列表
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getAllPersonNames(int scope, boolean distinct);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 查询指定范围下的所有用户信息
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 查询范围下返回的所有用户信息列表
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getAllPersons(int scope);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 根据Uid查询用户信息,*代表任意长度的任意字符
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户的uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户信息
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getPersonByUid(String uid, int scope);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 查询包含当前Cn信息的所有用户,*代表任意长度的任意字符
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param cn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户的cn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户列表
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getPersonByCn(String cn, int scope);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 使用LdapPersonInfo类对象实现复合查询,属性中可使用通配符*,*代表任意长度的任意字符
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param ldapPersonInfo
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 查询条件
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户列表
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getPersonByPersonEnty(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LdapPersonInfo ldapPersonInfo, int scope);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 根据dn查找用户,dn为base dn 的相对dn.(若basedn为:dc=koal,dc=com,user
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* dn为:uid=123,dc=koal,dc=com,则此处只需要提供 123 作为参数)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param dn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 相对base dn的dn参数
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户信息
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public LdapPersonInfo getLdapObjectByDn(String dn);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 验证用户登陆
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param password
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户密码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 是否登陆成功
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public boolean userLogin(String uid, String password);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 查询用户user dn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户dn列表,当前目录节点下可能存在多个相同uid的多个user dn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getUserDnByUid(String uid);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
UserDaoLdap:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package ldap;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import java.util.List;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import ldap.pojo.LdapPersonInfo;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* access Ldap
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @author 张亮
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public interface UserDaoLdap ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 获得所有的用户名(ldap称cn),可根据第二个参数指定返回值是否重复
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param distinct
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* true,去掉结构中的重复值;false 允许结果中包含重复值
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 查询范围下返回的cn列表
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getAllPersonNames(int scope, boolean distinct);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 查询指定范围下的所有用户信息
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 查询范围下返回的所有用户信息列表
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getAllPersons(int scope);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 根据Uid查询用户信息,*代表任意长度的任意字符
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户的uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户信息
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getPersonByUid(String uid, int scope);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 查询包含当前Cn信息的所有用户,*代表任意长度的任意字符
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param cn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户的cn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户列表
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getPersonByCn(String cn, int scope);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 使用LdapPersonInfo类对象实现复合查询,属性中可使用通配符*,*代表任意长度的任意字符
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param ldapPersonInfo
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 查询条件
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param scope
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 取值为0、1、2,分别对应 SearchControls 类 OBJECT_SCOPE, ONELEVEL_SCOPE,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* SUBTREE_SCOPE三个查询范围,分别代表 当前对象查询、当前节点下对象查询、当前节点所有子目录查询
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户列表
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getPersonByPersonEnty(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LdapPersonInfo ldapPersonInfo, int scope);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 根据dn查找用户,dn为base dn 的相对dn.(若basedn为:dc=koal,dc=com,user
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* dn为:uid=123,dc=koal,dc=com,则此处只需要提供 123 作为参数)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param dn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 相对base dn的dn参数
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户信息
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public LdapPersonInfo getLdapObjectByDn(String dn);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 验证用户登陆
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param password
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户密码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 是否登陆成功
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public boolean userLogin(String uid, String password);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/** *//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 查询用户user dn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* 用户uid
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @return 用户dn列表,当前目录节点下可能存在多个相同uid的多个user dn
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public List getUserDnByUid(String uid);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- #JAVA操作LDAP
- 如何使用Java操作LDAP之LDAP连接(一)
- JAVA_基本LDAP操作实例
- java使用虚拟属性操作LDAP(opends)用户,角色,组
- 【备忘】Java LDAP 相关操作
- java代码LDAP操作(增删改查)AD(活动目录)- 添加
- java简单操作 ldap
- LDAP学习笔记<四>jldap实现Java对LDAP的基本操作
- 用JAVA通过JNDI操作活动目录(AD)中LDAP
- 使用Java操作LDAP案例
- JAVA操作LDAP总结
- JAVA操作LDAP总结
- java对Ldap操作4
- ubuntu在安装LDAP服务器,在windows客户端下查看,并使用java操作LDAP
- Java操作AD域LDAP操作学习日志
- 如何使用Java操作LDAP之检索条目(二)
- Java操作AD Ldap错误备忘
- Java LDAP操作
- Java LDAP操作
- java代码LDAP操作(增删改查)AD(活动目录)- 删除