2017-04-10 36 views
2

我正在使用LDAP Microsoft Active Directory和Domino服务器,并且对此很新。通过Java代理获取Domino Xpages NamePicker中的所有Microsoft Active Directory用户

我们已经通过Java代理成功提取Domino中的所有Microsoft Active Directory用户,并在java调试控制台中打印了所有用户名。对于这个提到这个http://lotus-blogs.blogspot.in/2009/08/ldap-programming-using-domino-java-step.html链接。

现在,我想要获得Domino Xpages NamePicker中的所有用户,那么是否有可能通过java代理获取Xpages NamePicker中的所有用户?

正如我们在Xpages NamePicker中看到的那样,我们可以借助java bean来获取Domino用户。

任何类型的建议将真正赞赏。

我的Java代理是以下各项

import lotus.domino.*; 

public class JavaAgent extends AgentBase { 

    public void NotesMain() { 

     try { 
      Session session = getSession(); 
      AgentContext agentContext = session.getAgentContext(); 

      LDAPQuery.ldapconnect(); 

     } catch(Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 

import javax.naming.*; 
import javax.naming.directory.*; 
import java.util.*; 

public class LDAPQuery { 

public static void ldapconnect(){ 

String isFound="0"; 

try { 

    System.out.println("inside try 1"); 
Hashtable env = new Hashtable(); 
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); 
env.put(Context.PROVIDER_URL, "PROVIDER_URL"); 
env.put(Context.SECURITY_PRINCIPAL, "UserName"); 
env.put(Context.SECURITY_CREDENTIALS, "password"); 
// Create initial context 
DirContext ctx = new InitialDirContext(env); 
// Specify the ids of the attributes to return 
String[] attrIDs = {"cn","mail"}; 
SearchControls ctls = new SearchControls(); 
ctls.setReturningAttributes(attrIDs); 
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); 

String filter = "(&(objectCategory=person)(mail=*abc.com))"; 
System.out.println("filter defined"); 
// Search for objects that have those matching attributes 
NamingEnumeration answer = ctx.search("", filter,ctls); 

System.out.println("get the answer!"); 
try { 

    System.out.println("inside try2"); 
while (answer.hasMore()) 
{ 
SearchResult sr = (SearchResult)answer.next(); 
System.out.println("<<" + sr.getName()+">>"); 
Attributes attrs = sr.getAttributes(); 
//System.out.println(sr.getName().matches("/^[0-9]/")); 
System.out.println(attrs.get("cn").get()); 
System.out.println(attrs.get("mail").get()); 
isFound="1"; 
} 

if (isFound=="1") { 
System.out.println("User found in Active Directory!"); 
} else { 
System.out.println("Opps ! User not found in Active Directory!"); 
} 
answer.close(); 
}catch(PartialResultException e) { 

    System.out.println("catch 2"); 
e.printStackTrace(); 
} 
// Close the context when we're done 
ctx.close(); 
} catch (Exception e) { 

    System.out.println("catch 1"); 
e.printStackTrace(); 
} 

} 

public LDAPQuery() { 
// Don't think I'm doing anything here 
} 
} 
+0

您是否试过您的代码?你遇到问题了吗?如果是这样,他们是什么? –

+0

我们已经运行了代码,我们已经在java调试控制台中打印了所有的用户名,所有的用户名都根据需要正确打印。但问题是要将这些名称命名为选择器。因为名字选择器只有bean选项,但在我们的例子中,它是提供名称的Java代理。 –

回答

0

好,知道了。

你为什么要使用代理而不是使用真正的bean的任何特定原因?在我看来,每次有人打开名字选择器时拨打一个代理远远没有效果。

除此之外,我没有看到你的代理的结果如何直接传递到名称选择器。

第三:看看你的ldap过滤器我相信你的代码会返回数百甚至数千个名字。使用标准的ExtLib NamePicker对你的用户来说并不好玩,相信我:每个对话框页面显示的名字列表太有限了。但这可能是一个不同的故事。

坚持到namePicker方法有几种方法,你如何能达到你出现什么来完成:

  1. 重构你的Java代理到一个JavaBean然后将结果馈送到控制

  2. 考虑去找像IBM TDI这样的目录同步工具;因此您的AD数据可以被推送到您选择的Domino目录中,然后从您的应用程序中使用标准名称查找功能

相关问题