Since the ObjectPrincipal is the object that stores the user's rights settings, you will need to retrieve it from the InfoObject's SecurityInfo object. If the ObjectPrincipal does not exist, then you must add a new one to the ObjectPrincipals collection. The following segment tries to retrieve the ObjectPrincipal and adds a new one if it is not there:
Reports = IStore.Query("Select SI_ID From CI_INFOOBJECTS Where SI_ID="+ReportID);
SecurityInfo = Report.SecurityInfo;
Principal = SecurityInfo.ObjectPrincipals.Item("#"+UserID);
Principal = SecurityInfo.ObjectPrincipals.Add(UserID);
Note how the number symbol (#) must be concatenated to the UserID when you retrieve the ObjectPrincipal.
Go to the next section: Setting the right.
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |