请问有什么函数能够判断一个DN是否存在于LDAP服务器中
比如,我用ctx.lookup("cn=241,ou=user,dc=ibm,dc=com");如果这个dn是不存在的,就会直接报错
求高人指导
比如,我用ctx.lookup("cn=241,ou=user,dc=ibm,dc=com");如果这个dn是不存在的,就会直接报错
求高人指导
解决方案 »
- Java复写和泛型的问题
- JTable中某列加入JCombobox,当移动到jcombobox后,用上下键选择jcombobox中的内容,但是却跳入jtable的下一行,求解决方法.如图
- 泛型问题
- 2006年程序员考试的下午第8题
- 高分求教
- 2007年最新技术
- 如何提取各个像素的图象数据值[50分],回帖有帮助立即给分
- 求助:完数的定义!急
- 关于java的速度问题
- 急急急! 用javamail写了一个发信程序,可是报"javax.mail.NoSuchProviderException: No provider for pop3 pr
- jnative返回差数问题
- Eclipse运行含多个类的java程序,为什么老跳出Ant build对话框
但是,我是用的Serializable对象绑定ldap目录,这样好像对象里的属性只是存进了ldap数据库,search方法根本指定不了这些属性
比如我的User类有username,password两个属性,但是用search方法根本不能使用这个属性查找
求高手解答啊
在某一节点上下文可以通过搜索遍历对比
DirContext ctx = new InitialDirContext(env);
/* specify search constraints to search subtree */
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
/* search for all entries with surname of Jensen */
NamingEnumeration results
= ctx.search(Env.MY_SEARCHBASE, Env.MY_FILTER, constraints);
/* for each entry print out name + all attrs and values */
while (results != null && results.hasMore()) {
SearchResult si = (SearchResult)results.next();
/* print its name */
System.out.println("name: " + si.getName());
Attributes attrs = si.getAttributes();
if (attrs == null) {
System.out.println("No attributes");
} else {
/* print each attribute */
for (NamingEnumeration ae = attrs.getAll();
ae.hasMoreElements();) {
Attribute attr = (Attribute)ae.next();
String attrId = attr.getID();
/* print each value */
for (Enumeration vals = attr.getAll();
vals.hasMoreElements();
System.out.println(attrId + ": " + vals.nextElement()))
;
}
}