Tuesday, January 16, 2024

Delete-AllAccounts-In-Applciation-Safely

 import java.util.List;

import sailpoint.api.SailPointContext;

import sailpoint.object.Filter;

import sailpoint.object.Identity;

import sailpoint.object.QueryOptions;

import java.util.List;

import sailpoint.api.Provisioner;

import sailpoint.api.SailPointContext;

import sailpoint.object.Identity;

import sailpoint.object.Link;

import sailpoint.object.ProvisioningPlan;

import sailpoint.object.ProvisioningProject;

import sailpoint.object.ProvisioningPlan.AccountRequest;


try {

ProvisioningPlan plan = new ProvisioningPlan();

List identityList = context.getObjects(Identity.class);

for (Identity identity : identityList) {

if (identity != null && (!"prasad".equals(identity.getName())))

{

plan.setIdentity(identity);

List links = identity.getLinks();

if (links != null && links.size() > 0) {

for (Link linkObj : links) {

if (linkObj != null && "Mighty App".equals(linkObj.getApplicationName())) {

AccountRequest accountRequest = new AccountRequest();

accountRequest.setOperation(AccountRequest.Operation.Delete);

accountRequest.setNativeIdentity(linkObj.getNativeIdentity());

accountRequest.setApplication(linkObj.getApplicationName());

plan.add(accountRequest);

}

}

}

Provisioner provisioner = new Provisioner(context);

ProvisioningProject project = provisioner.compile(plan);

provisioner.execute(project);

}

}

} catch (Exception e) {

log.error("exception occurred at: "+e.getMessage());

}

No comments:

Post a Comment

Fetch Members from Workgroup

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