How to retrieve all Groups (not member) defined in Identity Manager
search cancel

How to retrieve all Groups (not member) defined in Identity Manager

book

Article ID: 10495

calendar_today

Updated On:

Products

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

Issue/Introduction

How to retrieve all Groups (not member) defined in Identity Manager.

 

There is the method sigmaServices.getGroup(groupId) but it returns a single group that matches the ‘groupId’ value. This method isn’t supposed to return all the groups, otherwise its name would probably be ‘getGroups’. 

 



Environment

Identity Suite 14.0.1

Resolution

A simple way to retrieve all groups in a Identity Portal form context, without using a plugin: 

1. In the admin task (on Identity Manager side) that the Identity Portal form uses, add a Screen Logical Attribute with the following initialization javascript code: 

 

function init(FieldContext){ 

 

var gp = FieldContext.getGroupProvider(); 

var groupsInScope = new java.util.Vector(); 

var result = ""; 

 

groupsInScope = gp.findGroups(null,null,null); 

for (var i = 0; i < groupsInScope.size(); i++) { 

result += groupsInScope.get(i).getFriendlyName() + "$$"; 

 

FieldContext.setValue(result); 

 

This code will populate the field with a string constructed of all the groups names concatenated with a “$$” separator between each group. Notice that if you have groups with names that contain the “$$” string then a different separator should be used. 

 

 

2. Restart the Identity Manager connector on the Portal side. Then later, in the Identity Portal form, add a property and set its Target Name to the field from the previous step. When this form is initiated the property will be populated with the same string containing all the groups names. You can then parse the string in the form property’s Initialization handler and use it as you like. 

 

For example, if the form property is of type ‘Drop down’, the following code will populate its options list with all the groups names: 

 

var groups = prop.value.split('$$'); 

prop.options = []; 

 

for (var i = 0; i < groups.length; i++) { 

if (groups[i]){ 

prop.options.push({name:groups[i], value:groups[i]}); 

 

This is the way to retrieve all groups.