How to fetch any custom attribute for a user in a BLTH.
search cancel

How to fetch any custom attribute for a user in a BLTH.

book

Article ID: 51635

calendar_today

Updated On:

Products

CA Directory CA Identity Manager CA Identity Governance CA Identity Portal CA Risk Analytics CA Secure Cloud SaaS - Arcot A-OK (WebFort) CLOUDMINDER ADVANCED AUTHENTICATION CA Secure Cloud SaaS - Advanced Authentication CA Secure Cloud SaaS - Identity Management CA Secure Cloud SaaS - Single Sign On CA Security Command Center CA Data Protection (DataMinder) CA User Activity Reporting

Issue/Introduction

Let's assume you have a single-valued attribute defined on the User object in your directory.xml as follows:

<ImsManagedObjectAttr physicalname="<AttributeName>" displayname="<DisplayNameExample>" description="<Description>"
valuetype="String" required="false" multivalued="false" wellknown="%<WellKnown>%" maxlength="0"/>

You need to write a business logic task handler (BLTH) for the Create Group task. This BLTH needs to retrieve the value of the %<WellKnown>% for the administrator running the Create Group task and then do further computations with it. This field is not present on the task and the User object that a BLTHContext returns does not always have access to all the User's attributes.

So what is the best way to retrieve this value in the code?

Environment

Release:
Component: IDMGR

Resolution

Write some code within the BLTH that essentially grabs the user object from the directory directly and then gets all the user's attributes.

Here's a code snippet example for grabbing the %<WellKnown>% value:

String adminDN = blthContext.getAdministrator().getUniqueName(); //returns you the admin's full DN
(you can also do String adminDN = blthContext.getAdminUniqueName() //to return the admin's full DN
UserProvider up = blthContext.getUserProvider();
User curAdmin = up.findUser(adminDN,null); //the null here indicates to include all profile attributes
String hd_admin = curAdmin.getAttribute("%<WellKnown>%");

Note: the USER getAdministrator method which is available from the blthContext, and does return a USER object, does not provide access to the user profile attributes. Only a USER object retrieved via the user provider interface will provide this access.