문제

Hi i when i get the username from domino designer in the below mentioned way

    Session session = getSession();
    AgentContext agentContext = session.getAgentContext();
    String userName=session.getUsername(); 
    system.out.println("UserName="+uesrName);

i am getting the username in the format "CN= example/OU= Server/O=company" but i want to be in the usual format like example@abc.com .Can anyone please tell how to get it in Java.Is there any other approach to get the username in the expected format.please help.It would be great if some references are provided.

도움이 되었습니까?

해결책

example@abc.com is NOT a username but an email- address (that can be used in the username field to login for Webservices / traveler / ldap / etc. if the server is configured accordingly).

There are different ways to get an email- address for a given username, the easiest might be the usage of the Directory- Class and its method "lookupNames".

Here is an example taken from the Designer Help:

  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 help can be found in many places (locally installed if Designer is installed) or e.g. here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top