TM1 Security: cleaning up clients and groups

Ideas and tips for enhancing your TM1 application
Post Reply
Wim Gielis
MVP
Posts: 3105
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

TM1 Security: cleaning up clients and groups

Post by Wim Gielis »

Hi there

I wrote a TI process to clean up the }Clients and }Groups dimension. The process allows a parameter to define what you want to clean up.

- Typ C to remove clients that are in not a single group
- Typ G to remove groups that contain no clients
- Typ CG to do both

This is done in 1 process. If you choose CG, the process executes itself with a C and then with a G.

The process avoids the double loop over clients and groups (since the combination matters). The data source is a subset on the relevant dimension, and then in the code a loop is made over the elements in the other dimension. I use the statements DataSourceType, DatasourceNameForServer and DatasourceDimensionSubset.

Of course, you need the relevant rights to execute the process. Client names and group names containing the word admin are skipped. Feel free to use attributes and the like to further customize the code.


Steps to follow:

Create a process called "Clean up clients and groups"
Set the data source as the subset ALL on the }Clients or }Gorups dimension (first choose View > Display control objects)
Call the only variable V1
Add a parameter: pCleanUpWhat - String - CG - What do you want to clean up? Typ C for Clients, G for Groups, CG for Clients and Groups.
In the Prolog tab:

Code: Select all

IF(pCleanUpWhat@='CG');

     EXECUTEPROCESS('Clean up clients and groups','pCleanUpWhat','C');
     EXECUTEPROCESS('Clean up clients and groups','pCleanUpWhat','G');


ELSEIF(pCleanUpWhat@='C');

     DataSourceType='SUBSET';
     DatasourceNameForServer='}Clients';
     DatasourceDimensionSubset='ALL';


ELSEIF(pCleanUpWhat@='G');

     DataSourceType='SUBSET';
     DatasourceNameForServer='}Groups';
     DatasourceDimensionSubset='ALL';

ENDIF;
In the Metadata tab:

Code: Select all

IF(pCleanUpWhat@='C');

     vClient=V1;
     IF(SCAN('admin',vClient)=0);
          iGroup=1;
          vInAGroup=0;
          WHILE(iGroup<=DIMSIZ('}Groups'));
               vGroup=DIMNM('}Groups',iGroup);
               IF(SCAN('admin',vGroup)=0);
                    IF(CELLGETS('}ClientGroups',vClient,vGroup)@=vGroup);
                         vInAGroup=1;
                         iGroup=DIMSIZ('}Groups');
                    ENDIF;
               ENDIF;
               iGroup=iGroup+1;
          END;

          If(vInAGroup=0);
               DELETECLIENT(vClient);
          ENDIF;

     ENDIF;


ELSEIF(pCleanUpWhat@='G');

     vGroup=V1;
     IF(SCAN('ADMIN',UPPER(vGroup))=0);
          iClient=1;
          vHasClients=0;
          WHILE(iClient<=DIMSIZ('}Clients'));
               vClient=DIMNM('}Clients',iClient);
               IF(SCAN('ADMIN',UPPER(vClient))=0);
                    IF(CELLGETS('}ClientGroups',vClient,vGroup)@=vGroup);
                         vHasClients=1;
                         iClient=DIMSIZ('}Clients');
                    ENDIF;
               ENDIF;
               iClient=iClient+1;
          END;

          If(vHasClients=0);
               DELETEGROUP(vGroup);
          ENDIF;

     ENDIF;


ENDIF;
In the Epilog tab:

Code: Select all

SecurityRefresh;
Finished.


Best regards,

Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
Steve Rowe
Site Admin
Posts: 2410
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: TM1 Security: cleaning up clients and groups

Post by Steve Rowe »

Nice Work Wim, I have moved to the useful code forum. Thanks
Technical Director
www.infocat.co.uk
Wim Gielis
MVP
Posts: 3105
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: TM1 Security: cleaning up clients and groups

Post by Wim Gielis »

You're welcome ;)
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply