Setting the right

Before setting the right on the object, check that the right actually exists. If it doesn't, add it. For example:

if (!RightExists(Principal.Rights,RightID)) {

    //Add the right if it doesn't exist, even if it is removed later.

    Principal.Rights.Add(RightID);

}

function RightExists(Rights, RightID)

{

    Result=false;

    try {

        Result = Rights.Item("#" + RightID).Granted;

    }

    catch(e)

    {

        return false;

    }

    return true;

}

Note that if you try to retrieve a right that doesn't exist, the call actually fails. Once you have the right, you can set the Granted property. For example,

Principal.Rights.Item("#"+Right.ID).Granted=true;

Once you have modified the rights, you store them back to the server using InfoStore.Commit:

IStore.Commit(Reports);

Recall that Reports was retrieved in Retrieving and adding the ObjectPrincipal.

Go to the next step, Setting the role.



Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com