If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Removing reports that belong to a user

Started by woowoo, 08 Apr 2008 12:27:23 PM

Previous topic - Next topic

woowoo

When removing user accounts from our Access Manager, for some reason, the reports that the user owns are not being removed. As we have about 200+ accts to remove, we are looking for a way to use the SDK to remove the reports before removing the accts, so we do not get orphaned reports. Does anyone have this type of script already?

TIA

avitabj

Hi!  Here's a snippet of the code I use

userPath = namespaceSearchPath + "//account[@userName=\"" + username +"\"]";
PropEnum props[] = new PropEnum[]{   PropEnum.defaultName,
            PropEnum.modificationTime,
            PropEnum.screenTip,
            PropEnum.searchPath};   
try
{
   BaseClass[] user = oCrn.query(userPath, props, new Sort[]{}, new QueryOptions());
   if (user.length == 0)
   {
      (unknown user)   
             }
   else
   {
   //   if user has modification time then they've logged in to ReportNet and have a My Folders
      if (user[0].getModificationTime().getValue() != null)
      {
         //   Get name of My Folders folder, user can change
         String userFolderPath = user[0].getSearchPath().getValue() + "/child::folder";
         PropEnum folderprops[] = new PropEnum[] {PropEnum.searchPath,
                                                                            PropEnum.objectClass,
                  PropEnum.modificationTime,                        PropEnum.defaultName};
         //Query the Content Store for user's folder
         try
         {
            BaseClass bc[] = oCrn.query(userFolderPath, folderprops, new Sort[]{}, new QueryOptions());
            if (bc != null && bc.length > 0)
            {
               //   delete user's My Folders and all it's contents
               DeleteOptions del = new DeleteOptions();
               del.setForce(true);         //   this option will force the delete regardless of owner
               del.setRecursive(true);   //   this option will delete all children
               try
               {
                  BigInteger rc = oCrn.delete(new BaseClass [] {bc[0]}, del);

yadayadayada

hth...jean



Darek

Keep in mind this code should be executed BEFORE a user is deleted. Afterwards the userName attribute will be absent.

avitabj

judging from the sunday date on your post, i hope you didn't find out the hard way that you need to do the delete reports first    if you did delete the user, i think you can still figure out what reports should be whacked by checking if the owner is null   i haven't had to do this but it seems logical

hth....jean