Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top