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

Read Group and Roles info of logged in user using Cognos SDK

Started by akhanchandani, 23 Dec 2009 05:21:34 AM

Previous topic - Next topic

akhanchandani

After a user logs in to Cognos through SDK how to retreive the logged in users Group and roles?

asaksena

The following code lists groups and roles for the current logon with associated permissions.

      PropEnum[] props = new PropEnum[] {PropEnum.searchPath,
            PropEnum.defaultName,
            PropEnum.userName,
            PropEnum.policies,
            PropEnum.permissions,
            PropEnum.notificationEMail} ;
      Account acct = null ;
      try {
         BaseClass bc[] = cmService.query(
            new SearchPathMultipleObject("~"),
            props, new Sort[] {}, new QueryOptions() ) ;
         if (bc!=null && bc.length>0)
            acct = (Account)bc[0] ;
      }
      catch (java.rmi.RemoteException e) {
         log.error(e) ;
      }
        for (int j = 0; j < acct.getPolicies().getValue().length; j++) {
         Policy pol = acct.getPolicies().getValue()[j];
         log.info(pol.getSecurityObject().getSearchPath().getValue()) ;
         Permission[] perm = pol.getPermissions();
         for (int k = 0; k < perm.length; k++) {         
            log.info(perm[k].getName()) ;
         }         
      }