Thursday, March 25, 2021

Move AD account from one OU to another OU

<Source>

  import java.util.*;
  import java.io.IOException;      
  import javax.faces.context.FacesContext;
  import javax.naming.ldap.LdapName;
  import javax.naming.ldap.Rdn;    
  import org.apache.log4j.Logger;

  import sailpoint.api.SailPointContext;
  import sailpoint.api.IdentityService;
  import sailpoint.api.ObjectUtil;
  import sailpoint.api.PersistenceManager;
  import sailpoint.api.Provisioner;

  import sailpoint.connector.ADLDAPConnector;
  import sailpoint.connector.Connector;

  import sailpoint.object.*;
  import sailpoint.object.Application;
  import sailpoint.object.Attributes;
  import sailpoint.object.Custom;
  import sailpoint.object.Filter;
  import sailpoint.object.Identity;
  import sailpoint.object.Link;
  import sailpoint.object.ManagedAttribute;
  import sailpoint.object.ProvisioningPlan;
  import sailpoint.object.ProvisioningPlan.AccountRequest;
  import sailpoint.object.ProvisioningPlan.AttributeRequest;
  import sailpoint.object.QueryOptions;  

  import sailpoint.tools.CloseableIterator;
  import sailpoint.tools.GeneralException;
  import sailpoint.tools.Message;
  import sailpoint.tools.Util;
  import sailpoint.workflow.WorkflowContext;

  // Disable AD Account and Move AD account from one OU to another OU
  public ProvisioningPlan buildMoveADAccountsPlan(WorkflowContext wfc)
    throws GeneralException{

    String methodName = "buildMoveADAccountsPlan";
    Logger ruleLog = Logger.getLogger("RuleLog");

    String nativeIdentity = null;
    String newOU = null;  

    System.out.println("Entering into buildMoveADAccountsPlan rule");
    ruleLog.error("Entering into buildMoveADAccountsPlan rule");

    if (ruleLog.isDebugEnabled()) {ruleLog.error("Entering into buildMoveADAccountsPlan rule");}

    Attributes args = wfc.getArguments();  
    System.out.println("Attributes = "+args);
    ruleLog.error("Attributes = "+args);

    String op = Util.getString(args, "op");
    System.out.println("Operation = "+op);
    ruleLog.error("Operation = "+op);

    if ( op == null ){

      throw new GeneralException("Operation (op) must be specified.");
    }

    ProvisioningPlan plan = new ProvisioningPlan();
    SailPointContext context = wfc.getSailPointContext();
    System.out.println("SailPointContext = "+context);
    ruleLog.error("SailPointContext = "+context);

    //  Custom settings = context.getObjectByName(Custom.class, "Custom Settings");      

    String identityName = Util.getString(args, "identityName");
    System.out.println("identityName = "+identityName);
    ruleLog.error("identityName = "+identityName);

    if (ruleLog.isDebugEnabled()) {

      System.out.println("Processing identity " + identityName);
      ruleLog.error("Processing identity " + identityName);
    }

    Identity identity = context.getObjectByName(Identity.class, identityName);      

    if (null != identity) {

      plan.setIdentity(identity);

      // Get a list of AD applications
      List appList = getADApps();
      System.out.println("appList = "+appList);
      ruleLog.error("appList = "+appList);

      IdentityService identityService = new IdentityService(context);

      for (Application app : appList) {

        List links = identityService.getLinks(identity, app);
        System.out.println("List of links are = "+links);
        ruleLog.error("List of links are = "+links);

        // Application application = context.getObjectByName(Application.class, app);

        String appType = app.getType();
        System.out.println("appType is = "+appType);
        ruleLog.error("appType is = "+appType);

        if ("Active Directory - Direct".equals(app.getType())){

          Attributes attributes = app.getAttributes();
          System.out.println("Attributes are : "+attributes);
          ruleLog.error("Attributes are : "+attributes);

          List searchdns = attributes.getList("searchDNs");
          System.out.println("searchdns are : "+searchdns);
          ruleLog.error("searchdns are : "+searchdns);


          /*  List dn = list.get("searchDN");

          System.out.println("dn are : "+dn);
          ruleLog.error("dn are : "+dn);*/

          Iterator itr = searchdns.iterator();

          while(itr.hasNext()){

            String searchDN = itr.next().get("searchDN").toString();
            System.out.println("Users OU is : "+searchDN);
            ruleLog.error("Users OU is : "+searchDN);

            boolean flag = searchDN.toLowerCase().contains("disabled users");
            //boolean flag = searchDN.toLowerCase().contains("Disabled Users");

            System.out.println("flag... : "+flag);
            ruleLog.error("flag..... : "+flag);

            if(flag){
              System.out.println("Disabled Users OU is... : "+searchDN);
              ruleLog.error("Disabled Users OU is..... : "+searchDN);
            }
          }
        }

        if ((null != links) &amp;&amp; !links.isEmpty()) {

          for (Link link : links) {

            nativeIdentity = link.getNativeIdentity();
            System.out.println("nativeIdentity is : "+nativeIdentity);
            ruleLog.error("nativeIdentity is : "+nativeIdentity);

            // Disable the AD account
            if (ruleLog.isDebugEnabled()){
              ruleLog.error("Disabling account " + link.getNativeIdentity() + " in application " + link.getApplicationName());
            }

            AccountRequest acctReq = new AccountRequest();

            acctReq.setApplication(link.getApplicationName());
            acctReq.setInstance(link.getInstance());
            acctReq.setNativeIdentity(nativeIdentity);
            acctReq.setOperation(AccountRequest.Operation.Disable);        

            //  acctReq.add(new AttributeRequest("IIQDisabled","true"))

            // String dn = link.getAttribute("distinguishedName");

            if(op.equals("Disable")) {

              if (nativeIdentity.toLowerCase().contains("dc=mightypedia,dc=com")) {

                //newOU = "ou=Disabled Users,dc=maxcrc,dc=com";

                newOU="ou=Disabled Users,dc=mightypedia,dc=com";

                //newOU = settings.get("Disabled Users");
                //System.out.println("newOU is : "+newOU);

                System.out.println("cn=" +nativeIdentity+","+"Dynamically getting Disable OU is : "+newOU);
                log.error("cn=" +nativeIdentity+","+"Dynamically getting Disable OU is : "+newOU);

              }
            }
            if(ruleLog.isDebugEnabled()){System.out.println("Moving to : "+newOU);ruleLog.error("Moving to : "+newOU);}

            if(null!=newOU&amp;&amp;!newOU.equalsIgnoreCase(getParentContainerDN(nativeIdentity))){

              AccountRequest acctReq = new AccountRequest();

              acctReq.setApplication(link.getApplicationName());
           //   acctReq.setInstance(link.getInstance());
              acctReq.setNativeIdentity(link.getNativeIdentity());
              acctReq.setOperation(AccountRequest.Operation.Modify);

             // AttributeRequest attReq = new AttributeRequest();

            //  attReq.setName("AC_NewParent");
           //   attReq.setValue(newOU);
           //   attReq.setOp(ProvisioningPlan.Operation.Set);
           //   acctReq.add(attReq);
             acctReq.add(new AttributeRequest ("AC_NewParent", ProvisioningPlan.Operation.Set, newOU));
              plan.setIdentity(identity);
              plan.add(acctReq);

              System.out.println("*************Compiling starts for ProvisioningPlan*******************");

              Provisioner provisioner = new Provisioner(context);
              ProvisioningProject project = provisioner.compile(plan);
              provisioner.execute(project);

              System.out.println("*****************Compilation has completed for ProvisioningPlan *********");                                                                

            }          
          }
        }
      }
    }

    if(ruleLog.isDebugEnabled()){
      System.out.println("Returning plan: "+plan.toXml());ruleLog.error("Returning plan: "+plan.toXml());
    }

    return plan;
  }

  // Get the parent container DN of an LDAP full DN    
  public String getParentContainerDN(String dn) {

    String methodName = "getParentContainerDN";
    System.out.println("Entering into the method : "+methodName);      

    LdapName ln = new LdapName(dn);
    String parentDN = ln.getPrefix(ln.size() - 1).toString();    

    System.out.println("Parent ContainerDN : "+parentDN);        
    System.out.println("Exiting from the method : "+methodName);  

    return parentDN;      
  }

  // Get a list of all the AD applications
  public List getADApps() {

    String methodName = "getADApps";
    Logger ruleLog = Logger.getLogger("rule.RuleLog");

    System.out.println("Entering into the method : " + methodName);
    ruleLog.error("Entering into the method : " + methodName);


    List appList = new ArrayList();

    QueryOptions qo = new QueryOptions();
    qo.addFilter(Filter.eq("connector", "sailpoint.connector.ADLDAPConnector"));

    Iterator it = context.search(Application.class, qo);

    while (it.hasNext()) {

      Application thisApplication = it.next();

      if (ruleLog.isDebugEnabled()) {
        System.out.println("Found AD application " + thisApplication.getName());
        ruleLog.error("Found AD application " + thisApplication.getName());
      }

      appList.add(thisApplication);
    }
    if (appList.isEmpty()) {
      System.out.println("No AD Directory applications found");
      ruleLog.error("No AD Directory applications found");
    }

    System.out.println("Exiting from the method : " + methodName);
    ruleLog.error("Exiting from the method : " + methodName);

    return appList;
  }
  </Source>

Leaver Event Rule

 System.out.println("Entering into Leaver Event Rule : ");

 String status = newIdentity.getAttribute("status");

 System.out.println("status : "+status);

  if(status != null){

    if(status.equalsIgnoreCase("Terminated Employee")){

      boolean flag = true;

      System.out.println("Entering into Leaver Event Rule : "+flag);      

      return flag;

    }

       else {

          boolean flag = false;

         System.out.println("Entering into Leaver Event Rule : "+flag);

               return flag;

       }

 System.out.println("Exiting from the Leaver Event Rule : ");

       }

Tuesday, March 23, 2021

How to set up vm ware in windows

 Pre-requisites :-

1. Download the VM ware from the following URL:

Download VMware Workstation Player | VMware | IN

Steps

1. Go to VM ware software path and right click on VM ware software and select Run as Administrator.

2. Click on Next

3.  Check the box [I accept the terms in license Agreement] and click on Next

4.  Click on Next

5. Uncheck both the check boxes (User experience settings) and click on Next

6. Uncheck Start Menu Program Folder and click on Next

7. Click on Install

8. Click on Finish 


*************************** VM ware set up is completed ****************************

Monday, March 22, 2021

How to connect mysql through cmd

 Steps: 

1. Go to MySQL installation directory then until the bin

Ex: C:\Program Files\MySQL\MySQL Server 8.0\bin

2. Open cmd from the above path 

(OR)

Navigate to the Windows icon, search for cmd, and click on Command Prompt

3. Enter the following command in cmd

cd C:\Program Files\MySQL\MySQL Server 8.0\bin

4. mysql -u root -p (mysql -u reddy -p)

NOTE: root is the default username, if you have used a custom username, as mentioned like above

5. Enter the password: *******

6. show databases;

(this command will display the lists of databases)

======================================================================

  • create database trakk;
  • show databases;
  • use trakk;
  • source D:\IDM\Sailpoint\Sailpoint\Sailpoint Documentation\Sailpoint Lab Exercises\Version 7.0\trakk.sql;


My SQL Installation

 Follow the below URL's for installing MYSQL ::-

How to Install MySQL on Windows 10 (Step-By-Step Guide) (smarttechnicalworld.com)

Install MySQL on Windows 10 Step by Step | OnlineTutorialsPoint

How to download and install MySQL on Windows 10? (roseindia.net)

How To Install MySQL in Windows 10 - Step-By-Step Tutorials - MobyGeek.com

How To Install MySQL in Windows 10?(Easy Step By Step Guideline) - FixGuider


Thursday, March 18, 2021

List of Sailpoint API's

# IdentityServiceA service layer that deals with identities.

IdentityService(SailPointContext context) : Constructor.


# WorkflowContext


How to Create Domain in Windows Server ?

Pre-requisites:

# VMware Software - Download VMware Workstation Pro
# Install VMware
# Install Windows Server


Steps for Active Directory Domain Services:-

1. Navigate Windows and search for Server Manager


2. Click on Server Manager

3. Click on Add Roles and Features.

4. Select the Role-based or Feature-based Installation option. Click on Next.

5. Select a server from the server pool option. Click on Next.

6. Select the Active Directory Domain Services.

7. Click on Add Features.

8. Click on Next.

9. Restart the destination server automatically if required option. Click on Install.



Steps for Domain Creation :-

1. Navigate Windows and search for Server Manager


2. Click on Server Manager


3. Navigate to the notification symbol (it's available on the top right side corner) and click on it.


4. Click on Promote this server to a domain controller

5. Select  Add a new Forest radio button and enter the domain name



6. Create a new password.

7.Click on Next ---> Next -----> Next ---> Install ---->Restart











BuildMap Rule

 BuildMap Rule    :

It's available for JDBC and Delimited File Connectors
# It's used for manipulating or changing schema attributes during iterations of file reading
# It will run during the Account Aggregations

e.g    : Changing or parsing account attributes (i.e., lastLogin ) to meet a specific date format

e.g    :    1

import sailpoint.object.Schema;
import sailpoint.connector.Connector;
import sailpoint.connector.DelimitedFileConnector;

private static final Logger LOGGER  = Logger.getLogger(“BuildMap Rule”);
if(schema.getObjectType().compareTo(Connector.TYPE_ACCOUNT) ==0)
{
HashMap map = DelimitedFileConnector.defaultBuildMap(cols,record);
LOGGER.debug("\n BuildMap before changing : "+map);

//Employee Rule sets EmployeeStatus to "Employee"
map.put("status","Employee");
LOGGER.debug\n BuildMap after changing : "+map);
return map;
}

e.g    :    2

import sailpoint.object.Schema;
import sailpoint.connector.Connector;
import sailpoint.connector.DelimitedFileConnector;

private static final Logger LOGGER  = Logger.getLogger(“BuildMap Rule”);
if(schema.getObjectType().compareTo(Connector.TYPE_ACCOUNT) ==0)
{
HashMap map = DelimitedFileConnector.defaultBuildMap(cols,record);
LOGGER.debug("\n BuildMap before changing : "+map);

//Employee Rule sets EmployeeStatus to "Contractor"
map.put("status","Contractor");
LOGGER.debug\n BuildMap after changing : "+map);
return map;
}

Tuesday, March 9, 2021

Move AD account from People OU to Disable OU & vice versa (Enable) in IIQ

public ProvisioningPlan buildMoveADAccountsPlan(WorkflowContext wfc) 

        throws GeneralException {


        Logger ruleLog = Logger.getLogger("RuleLog");

        if (ruleLog.isDebugEnabled()) ruleLog.debug("Entering into buildMoveADAccountsPlan rule");

        Attributes args = wfc.getArguments();      

        String op = Util.getString(args, "op");


        if ( op == null ){

           throw new GeneralException("Operation (op) must be specified.");

   }    

        Custom settings = context.getObjectByName(Custom.class, "Custom Settings");

        ProvisioningPlan plan = new ProvisioningPlan();

        String identityName = Util.getString(args, "identityName");

        if (ruleLog.isDebugEnabled()) ruleLog.debug("Processing identity " + identityName);

        Identity identity = context.getObjectByName(Identity.class, identityName);        


        if (null != identity) {

           plan.setIdentity(identity);         


           // Get a list of AD applications 

           List appList = getADApps();       

           IdentityService identityService = new IdentityService(context);

           for (Application app : appList) {

              List links = identityService.getLinks(identity, app);

              if ((null != links) &amp;&amp; !links.isEmpty()) {

                for (Link link : links) {

                   String nativeIdentity = link.getNativeIdentity();

                   String newOU = null;

                   if (op.equals("Disable")) {

                      if (nativeIdentity.toLowerCase().endsWith("dc=mightypedia,dc=com")){

                         newOU = settings.get("pediaADDisabledUsersOU");

}                 

                   } 

      }

             }

                   if (ruleLog.isDebugEnabled()) {

   ruleLog.debug("Moving to " + newOU);

   }

                   if (null != newOU &amp;&amp; ! newOU.equalsIgnoreCase(getParentContainerDN(nativeIdentity))) {

                      AccountRequest acctReq = new AccountRequest();

                      acctReq.setApplication(link.getApplicationName());

                      acctReq.setInstance(link.getInstance());

                      acctReq.setNativeIdentity(link.getNativeIdentity());

                      acctReq.setOperation(AccountRequest.Operation.Modify);

      AttributeRequest attReq = new AttributeRequest();


                      attReq.setName("AC_NewParent");

                      attReq.setValue(newOU);

                      attReq.setOp(ProvisioningPlan.Operation.Set);

                      acctReq.add(attReq);

                      plan.add(acctReq);

                   }           

                }

             }

           }

        }

        if (ruleLog.isDebugEnabled()) {

ruleLog.debug("Returning plan: " + plan.toXml());

}

        return plan;

    }

---------------------------------------------################----------------------------------------------

 public List getADApps() {    

        Logger ruleLog = Logger.getLogger("RuleLog");

        List appList = new ArrayList();

        QueryOptions qo = new QueryOptions();

        qo.addFilter(Filter.eq("connector", "sailpoint.connector.ADLDAPConnector"));      

        Iterator it = context.search(Application.class, qo);

        while (it.hasNext()) {

           Application thisApplication = it.next();

           if (ruleLog.isDebugEnabled()) ruleLog.debug("Found Active Directory application " + thisApplication.getName());

           appList.add(thisApplication);

        }         

        if (appList.isEmpty()) {

           ruleLog.warn("No Active Directory applications found");

        }

        return appList;

    }

IAM, IGA & Identity Security

IAM sets up the employee's account so they can log in and access the application with their credentials. IGA makes sure that access requ...

Featured Articles