# WebService Connector - delete and recreate of user account

**URL:** <https://developer.sailpoint.com/discuss/t/webservice-connector-delete-and-recreate-of-user-account/105285>\
**Category:** IIQ Discussion and Questions\
**Tags:** identityiq, provisioning, rules\
**Created:** [March 25, 2025, 5:39am UTC](https://developer.sailpoint.com/discuss/t/webservice-connector-delete-and-recreate-of-user-account/105285 "2025-03-25T05:39:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AkashRaavi131](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@AkashRaavi131](https://developer.sailpoint.com/discuss/u/AkashRaavi131)\
**Post date:** [March 25, 2025, 5:39am UTC](https://developer.sailpoint.com/discuss/t/webservice-connector-delete-and-recreate-of-user-account/105285/1 "2025-03-25T05:39:45Z")

</div>

Hi ,

We are having application that is requiring me to delete an account and recreate it in some cases rather than updating the existing account.  
Could anyone provide an approach for the above mentioned scenario.

Thanks,  
Akash

---

<div class="post-metadata">

**Author:** ![pdeloos](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/pdeloos/32/41894_2.png) [@pdeloos](https://developer.sailpoint.com/discuss/u/pdeloos)\
**Post date:** [March 25, 2025, 7:38am UTC](https://developer.sailpoint.com/discuss/t/webservice-connector-delete-and-recreate-of-user-account/105285/2 "2025-03-25T07:38:36Z")

</div>

Hello Akash,

There’s two options for you:

1. You could go for an account selector rule. This is a rule that is configured at role level, allowing you to tell IIQ to create a new account. It however does not tell IIQ to delete the old one.
2. You can implement a before provisioning rule that specifically checks if a certain entitlement (your ‘some case’) is added. If the case is detected, it can manipulate the provisioning plan to do the needful. I have added a code sample below:

```auto
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.Operation;

ProvisioningPlan newPlan = new ProvisioningPlan();

// Flag to check if the specific entitlement is present
boolean specificEntitlementAdded = false;

// Check if the specific entitlement is added in the original plan
for (AccountRequest accountRequest : plan.getAccountRequests()) {
    if (accountRequest.getAttributes() != null && accountRequest.getAttributes().containsKey("entitlementName")) {
        Object entitlementValue = accountRequest.getAttributes().get("entitlementName");
        if ("specificEntitlementValue".equals(entitlementValue)) {
            specificEntitlementAdded = true;
            break;
        }
    }
}

if (specificEntitlementAdded) {
    for (AccountRequest accountRequest : plan.getAccountRequests()) {
        // Create a delete request for the existing account
        AccountRequest deleteRequest = new AccountRequest();
        deleteRequest.setApplication(accountRequest.getApplication());
        deleteRequest.setNativeIdentity(accountRequest.getNativeIdentity());
        deleteRequest.setOperation(Operation.Delete);
        newPlan.add(deleteRequest);

        // Create a create request for the new account
        AccountRequest createRequest = new AccountRequest();
        createRequest.setApplication(accountRequest.getApplication());
        createRequest.setNativeIdentity(accountRequest.getNativeIdentity());
        createRequest.setOperation(Operation.Create);
        createRequest.setAttributes(accountRequest.getAttributes());
        newPlan.add(createRequest);
    }

    // Add other attribute requests from the old plan to the new plan
    for (ProvisioningPlan.AttributeRequest attributeRequest : plan.getAttributeRequests()) {
        newPlan.add(attributeRequest);
    }
    
    return newPlan;
} else {
    // If the specific entitlement is not added, return the original plan
    return plan;
}

```

The above rule can be used as a before provisioning rule. It checks if the plan contains a specific entitlement. If so, it creates a new plan with a _delete_ request for the existing account and a _create_ request for a new account, containing the entitlements from the original plan. Please bear in mind that your application definition needs to support these operations.

Kind regards,  
Pieter.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [May 24, 2025, 7:38am UTC](https://developer.sailpoint.com/discuss/t/webservice-connector-delete-and-recreate-of-user-account/105285/3 "2025-05-24T07:38:41Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
