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

Document ID : KB000051635
Last Modified Date : 14/02/2018
Show Technical Document Details


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

<ImsManagedObjectAttr physicalname="dcgsExtraAttr2" displayname="HD Administrator" description="HD Administrator"
valuetype="String" required="false" multivalued="false" wellknown="%HD_ADMINISTRATOR%" 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 %HD_ADMINISTRATOR% 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?


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 %HD_ADMINISTRATOR% 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("%HD_ADMINISTRATOR%");

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.