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

Modify permissions on account

Started by rgroever, 08 Sep 2010 10:16:46 AM

Previous topic - Next topic

rgroever

Hi all,

i try to write a java SDK program that sets the permissions on the accounts of the authentication namespace.
By default each user has read, execute, traverse, modify and policy permissions.
I want to remove write and policy permission for all our standard users.

Currently i get a error message from the update funktion: "The property "policies" (for an object of class "account") is incorrect."

Anybody wrote a program successfully modifying the permissons of an account?

-----------------------------------------------------------------------------

public void allTargetPermissions (String targetSearchPath) throws Exception
    {
       boolean found = false;
       
       PropEnum[] props = new PropEnum[] {PropEnum.searchPath, PropEnum.policies};   
      BaseClass[] targetInfo = cmService.query(new SearchPathMultipleObject(targetSearchPath), props, new Sort[]{}, new QueryOptions());
       
      System.out.println ("Gefundene Accounts: " + targetInfo.length);
      System.out.println (targetInfo[0].getClass().getName());
      
      // default permissions for own account
      Permission[] permissions = new Permission[3];
      permissions[0]= new Permission();
      permissions[1]= new Permission();
      permissions[2]= new Permission();
      permissions[0].setName("read");
      permissions[0].setAccess(AccessEnum.grant);
      permissions[1].setName("execute");
      permissions[1].setAccess(AccessEnum.grant);
      permissions[2].setName("traverse");
      permissions[2].setAccess(AccessEnum.grant);

      
      // loop through each target account
      for(int i = 0; i < targetInfo.length; i++)
      {
         //System.out.println("Setting policy on: "+ targetInfo.getDefaultName().getValue() + " - "+ targetInfo.getSearchPath().getValue());
         
         // loop through policy objects
         for(int k = 0; k < targetInfo.getPolicies().getValue().length && !found; k++)
         {
            // note if policy object for account exists
            found = false;      
            Policy policy = targetInfo.getPolicies().getValue()[k];
            if(policy.getSecurityObject().getSearchPath().equals(targetInfo.getSearchPath()))
            {
               found = true;
            }
         }

         Policy[] newPolicies = new Policy[targetInfo.getPolicies().getValue().length+1];
         PolicyArrayProp pArray = new PolicyArrayProp();
         int k = 0;
         
         for(k = 0; k < targetInfo.getPolicies().getValue().length; k++)
         {
            
            Policy SinglePolicy = targetInfo.getPolicies().getValue()[k];
            if(!SinglePolicy.getSecurityObject().getSearchPath().equals(targetInfo.getSearchPath()))
            {
               newPolicies[k] = new Policy();
               newPolicies[k].setSecurityObject(SinglePolicy.getSecurityObject());
               newPolicies[k].setPermissions(SinglePolicy.getPermissions());            
            }
            else
            {
               newPolicies[k] = new Policy();
               newPolicies[k].setSecurityObject(SinglePolicy.getSecurityObject());
               newPolicies[k].setPermissions(permissions);
            }
         }
         
         if (!found)
         {
            newPolicies[k] = new Policy();
            newPolicies[k].setSecurityObject(targetInfo);
            newPolicies[k].setPermissions(permissions);
         }
         
         pArray.setValue(newPolicies);
         targetInfo.setPolicies(pArray);
            
         cmService.update(new BaseClass[]{targetInfo}, new UpdateOptions());
         
                     
         }

      }



lindero

Hi rgroever,

is the user still able to change its preferences when you set the policy to your kind of permissions? I was once thinking about it as well but left it because I think the user isn't enbale to change i.e. the language any more.

kind regards,
lindero