嗨,当我以下面提到的方式从domino设计师那里获得用户名时
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
String userName=session.getUsername();
system.out.println("UserName="+uesrName);
我的格式为" CN = example / OU = Server / O = company"但我希望采用像example@abc.com这样的通常格式。任何人都可以告诉我们如何用Java获取它。是否有任何其他方法可以获得预期格式的用户名。请帮助。如果有的话,那会很棒提供了参考资料。
答案 0 :(得分:1)
example@abc.com不是用户名,而是电子邮件地址(如果相应地配置了服务器,则可以在用户名字段中用于登录Webservices / traveler / ldap /等)。
获取给定用户名的电子邮件地址有多种方法,最简单的方法可能是使用Directory-Class及其方法“lookupNames”。
以下是Designer帮助中的示例:
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Directory dir = session.getDirectory("NameOfYourServer");
String userName=session.getUsername();
DirEntryCollection direc = dir.lookupNames("($Users)",userName,"email");
DirEntry dirent = direc.getFirstEntry()
while (dirent != null) {
String name = dirent.getItemValue("InternetAddress");
System.out.println(InternetAddress);
dirent = direc.getNextEntry(); }
可以在许多地方找到设计器帮助(如果安装了Designer,则在本地安装)或者here