Getting access to User attributes

Hi,

I have created a new directory service in the portal for our Active Diretory and can see all of the users in that service quite successfully. When i search for a user in the admin console I can see their User Id, First Name, Last Name, Email Address etc…

Now, when I am in a portlet, I would like to gain access to the Email Address property of the user to send mails from that person. Can I use the IContext somehow to get the Email Address attribute for the user? I can see how to get a IUserID and other such interfaces but not sure how to get the email attribute itself.

I am not using webMethods portlets so please don’t send any WM specific replies :slight_smile:

Many Thanks,
Paul

Here is a code snippet:

IContext context = getPortletContext();
IBizPolicyManager bizPolicyManager = (IBizPolicyManager) PortalSystem.getBizPolicyProvider();
IPrincipalAttributeBizPolicy papBizPolicy = (IPrincipalAttributeBizPolicy) bizPolicyManager.getBizPolicy(IBizPolicyNames.PRINCIPAL_ATTRIBUTE);
Map attributes = papBizPolicy.getAllAttributes(context, context.getUserDirectoryURI());

String email = userAttributes.get(“email”);

Thanks,
Sergei

Sergei,

Apologies, I forgot to reply to this. That worked fine with a couple of minor changes, just in case anyone needs the same:

  • the attribute is called mail not email
    -getPorletContext() only works in WM Portlets (certainly doesn’t work with Spring Portlets), to get round this use the following which can be found in the java docs:

IContext context = com.webMethods.portal.bizPolicy.impl.ContextFactory
.acquireContext(true);

Cheers,
Paul

Hi,
I’m looking for an API to set the user attributes from java program.

I’ve created a database directory service. I create users through a portlet and the user data is reflected in the portal.