Page 1 of 1

TM1 Security: cleaning up clients and groups

Posted: Sun Jul 19, 2009 11:20 am
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

Re: TM1 Security: cleaning up clients and groups

Posted: Tue Jul 21, 2009 12:26 pm
by Steve Rowe
Nice Work Wim, I have moved to the useful code forum. Thanks

Re: TM1 Security: cleaning up clients and groups

Posted: Tue Jul 21, 2009 9:15 pm
by Wim Gielis
You're welcome ;)