Retrieve logged in user in UserApp forms

Retrieve logged in user in UserApp forms

Sometimes you need to know which user is using a form of a workflow, e.g. to control the form fields depending on user attributes or group memberships. This is not a problem for the request form because UserApp provides the initiator as a process property. But the User Application does not provide a function or property telling you the DN of the user using an approval form.

The solution is a custom service that gets the user DN from the application server.

Here are the steps needed to add this functionality to the UserApp:


    1. Stop the application server and backup the IDM war file.

    2. Copy the IDM war into a temp directory and open the war with an archiving tool.

    3. Download one of the attached files according to your UserApp version.

    4. Rename the file from zip to jar and copy it into the WEB-INF/lib directory of the war file.

    5. Extract and open the UIControlRegistry.xml located in WEB-INF directory.

    6. Add the following lines in the service section of the UIControlRegistry.xml



 <service resultType="json" authenticated="true" config="true">
<key>loggedInUser</key>
<classname>de.computacenter.ims.nim.ua.ajaxservices.LoggedInUserService</classname>
</service>



  1. Save the UIControlRegistry.xml and copy it back to the WEB-INF directory of the IDM war.

  2. Copy the IDM war to the deploy directory of the application server and start the User Application.


Now you can execute the service within a script of any workflow form.
	var loggedInUser;
var serviceResult = IDVault.execService("loggedInUser", null);
if(serviceResult != null) {
loggedInUser = serviceResult._data.raw;
}


The loggedInUser variable now contains the DN of the user.

LoggedInUserService

LoggedInUserServiceV4
Labels (1)
Attachments

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Comments
I don't get this to work in IDM 4.5.
Maybe (possibly) this version does not work with this code.
I used V4 and get back undefined as the logged in user.
I uploaded the updated zip file which works for IDM 4.5. Go to forum link https://forums.netiq.com/showthread.php?54337-Activity-getUser%28%29-in-the-4-5-dashboard&p=261769#post261769
to get the new zip file.
Hi there, anybody aware whether there's another way of doing this in IDM 4.7.1+?
Btw. the last link provided by skoithodan does not show any content.
Just found this, but haven't tried it yet:
https://www.netiq.com/communities/cool-solutions/cool_tools/calling-idm-rest-apis-from-within-workflows/
Top Contributors
Version history
Revision #:
3 of 3
Last update:
‎2020-01-31 22:08
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.