In might happen that you have orphaned SIDs in your FileNet ACE security objects because the referenced user was deleted in your LDAP system. With the following script you can easily remove these orphaned SIDs from the objects in you object store.

importPackage(Packages.com.filenet.api.core);
importPackage(Packages.com.filenet.api.security);
importClass(Packages.com.filenet.api.constants.RefreshMode);
importClass(Packages.com.filenet.api.property.Properties);

function OnCustomProcess (CEObject) {
    CEObject.refresh();
    var apl = CEObject.get_Permissions();
    var iter = apl.iterator();
        var perm = null;
       while (iter.hasNext()) {
          perm = iter.next();
          if (perm.get_GranteeName().equals("S-1-97-1624379264-299793222-805356954-1491869445")){
               iter.remove();
               CEObject.save(RefreshMode.REFRESH);
               break;
      }
        }
     }

You can run the java script within the object stores Search “Bulk Actions”.

Run the script for each SIDs that you want to delete from the ACE.