How To Get Account Link Groups Using BeanShell Script

Hi @Rakesh007

You could use a rule to get the list of values. For Windows Local the groups attribute on the Link holds the list of group names that the account is a member of. In this code I’ve assumed your Windows application is called “Windows Local” and that there is only one Windows account per identity. You can modify the code if there can be more than one, but you would probably want a dropdown in the form to specify the account if that is the case.

  import sailpoint.api.IdentityService;
  import sailpoint.object.Application;
  import sailpoint.object.Identity;
  import sailpoint.object.Link;
 
  String appName = "Windows Local";

  List groups = new ArrayList();
  Application app = context.getObjectByName(Application.class, appName);
  IdentityService identityService = new IdentityService(context);
  List windowsLinks = identityService.getLinks(identity, app);

  if (null != windowsLinks && !windowsLinks.isEmpty()) {
    Link link = windowsLinks.get(0); // Assuming only one account
    groups = link.getAttribute("groups");
  }

  return groups;
3 Likes