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 = Rights.Item("#" + RightID).Granted;
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:
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 |