COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => SDK => Topic started by: akhanchandani on 23 Dec 2009 05:21:34 AM

Title: Read Group and Roles info of logged in user using Cognos SDK
Post by: akhanchandani on 23 Dec 2009 05:21:34 AM
After a user logs in to Cognos through SDK how to retreive the logged in users Group and roles?
Title: Re: Read Group and Roles info of logged in user using Cognos SDK
Post by: asaksena on 07 Jan 2010 03:04:12 PM
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()) ;
         }         
      }