Getting the current logged on user’s email address in Xpages


When I was looking to do this as a part of an xpages application where I am already getting the logged on user and the IP address that they are communicating with the server from – I thought that this would be an easy thing to complete and that I would consult David Leedy’s excellent Cheat sheet but not seeing what I was after searched for it online. Surprisingly I didn’t get many hits. Given the mechanism shown here for accessing the name of the logged on user

Used as a computed field on xpage

 

var uName = session.getEffectiveUserName().getCommon;

return uName;

or

sessionScope.userName = @Name(“[ABBREVIATE]”,session.getEffectiveUserName());

return @Name(“[ABBREVIATE]”,session.getEffectiveUserName());

So the solution for getting the email address of the currently logged on xpage user from domino directory

context.getUser().getMail();

Hope that helps someone else – found that in a snippet from the Mastering Xpages book !!