Wednesday, August 21, 2024

Create group in OpenLdap

import sailpoint.connector.Connector;
import sailpoint.connector.LDAPConnector;
import sailpoint.object.Application;
import sailpoint.object.Attributes;
import sailpoint.object.Link;
import sailpoint.object.Identity;
import sailpoint.api.SailPointContext;
import sailpoint.tools.GeneralException;
import sailpoint.tools.Util;
import java.util.HashMap;
import java.util.Map;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.BasicAttribute;

Application ldapApp = context.getObjectByName(Application.class, "Mighty Application Name"); // Replace with your LDAP application name

// Initialize the LDAP connector
Connector connector = ldapApp.getConnector();
LDAPConnector ldapConnector = (LDAPConnector) connector;


String groupName = "mygroup";  
String groupBaseDN = "ou=groups,dc=example,dc=com";  
String gidNumber = "1234";  

// Prepare attributes for the new group
Attributes<String, Object> groupAttrs = new Attributes<>();
groupAttrs.put("cn", groupName);
groupAttrs.put("objectClass", Util.list("top", "posixGroup"));
groupAttrs.put("gidNumber", gidNumber);

try {
    ldapConnector.createObject(context, "group", groupAttrs, groupBaseDN + ",cn=" + groupName);

    
} catch (GeneralException e) {
    System.out.println("GeneralException: " + e.getMessage());
}

Wednesday, August 7, 2024

how to fetch IT roles based on entitlements in SailPoint IIQ?

import java.util.ArrayList;
import java.util.List;
import sailpoint.api.SailPointContext;
import sailpoint.object.Bundle;
import sailpoint.object.Filter;
import sailpoint.object.Profile;
import sailpoint.object.QueryOptions; 

String appName="Mighty";
String entitlementName = "DPA";
QueryOptions profileQo = new QueryOptions();
profileQo.addFilter(Filter.eq("application.name", appName));


  List bundles = new ArrayList();
  List profiles = context.getObjects(Profile.class, profileQo);

  if (profiles != null) {
    for (Object profileObj : profiles) {
      Profile p = (Profile) profileObj;
      List constraints = p.getConstraints();
      List filterList = null;
  
      if (constraints != null) {
        for (Object filter : constraints) {

          filterList = new ArrayList();
          if (filter instanceof sailpoint.object.Filter.LeafFilter) {
            sailpoint.object.Filter.LeafFilter f = (sailpoint.object.Filter.LeafFilter) filter;

            //Filter can have multiple values 
            Object value = f.getValue();

            if (value instanceof ArrayList) {

              ArrayList entitlements = new ArrayList();
              entitlements = (ArrayList) value;

              for (Object obj : entitlements) {
                if (obj.toString().equals(entitlementName)) {

                  Bundle bun = p.getBundle();
                  bundles.add(bun.getName());
                }

              }

            }

          }

        }

      }

    }

  }

  return bundles;

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...