{"record":{"id":"0c6a28a4998c896b","repo":"dotnet/wpf","slug":"sr-rmproviderexceptionnotownerofdocument-0c6a28","errorCode":null,"errorMessage":"SR.RMProviderExceptionNotOwnerOfDocument","messagePattern":"SR\\.RMProviderExceptionNotOwnerOfDocument","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementProvider.cs","lineNumber":646,"sourceCode":"    /// of licenses.\n    /// </summary>\n    /// <param name=\"licenses\">\n    /// The list of licenses from which to generate a publish license</param>\n    /// <param name=\"validUntil\">\n    /// The optional date until when the publish license will be valid</param>\n    /// <param name=\"referralUri\">\n    /// A URI to contact to request additional permissions</param>\n    void IRightsManagementProvider.GenerateUnsignedPublishLicense(\n        IList<RightsManagementLicense> licenses)\n    {\n        ArgumentNullException.ThrowIfNull(licenses);\n\n        // If the document is already protected, only owners can republish it\n        // with different permissions\n        if (IsProtected && !HasPermission(\n            _rmUseLicense, RightsManagementPermissions.AllowOwner))\n        {\n            throw new InvalidOperationException(\n                SR.RMProviderExceptionNotOwnerOfDocument);\n        }\n\n        Trace.SafeWrite(\n            Trace.Rights, \"Creating a publish license for the document.\");\n\n        //\n        // Create the unsigned publish license\n        //\n\n        UnsignedPublishLicense unsignedPublishLicense = null;\n\n        unsignedPublishLicense = new UnsignedPublishLicense();\n\n        ICollection<ContentGrant> licenseGrants =\n            GetGrantsFromUnsignedLicense(unsignedPublishLicense);\n\n        //","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementProvider.cs#L628-L664","documentation":"GenerateUnsignedPublishLicense lets owners republish a document with different permissions. If the document is already protected and the current use license does not grant AllowOwner, it throws RMProviderExceptionNotOwnerOfDocument, preventing non-owners from altering access rights.","triggerScenarios":"Calling GenerateUnsignedPublishLicense on an already-protected package while the bound use license lacks RightsManagementPermissions.AllowOwner.","commonSituations":"Non-owner attempts to re-permission someone else's protected document; app runs under a different user than the document owner; owner license not loaded before republishing.","solutions":["Load/acquire the owner's use license (with AllowOwner) before generating a new publish license","Have an owner perform the republish, or generate a fresh document/license instead of republishing","Check HasPermission(existing license, AllowOwner) up front and show an appropriate error in the UI"],"exampleFix":"// before\nvar newLicense = provider.GenerateUnsignedPublishLicense(grants);\n// after\nif (!provider.IsProtected || ownerHasAllowOwner)\n    var newLicense = provider.GenerateUnsignedPublishLicense(grants);\nelse\n    throw new UnauthorizedAccessException(\"Only the owner can republish this document.\");","handlingStrategy":"validation","validationCode":"var lic = GetUseLicense();\nif (provider.IsProtected && (lic == null || !lic.HasPermission(RightsManagementPermissions.AllowOwner)))\n    throw new InvalidOperationException(\"Owner rights required to republish.\");","typeGuard":"bool CanRepublish(IRightsManagementProvider p) => !p.IsProtected || p.HasPermission(p.UseLicense, RightsManagementPermissions.AllowOwner);","tryCatchPattern":"try { provider.GenerateUnsignedPublishLicense(grants); }\ncatch (InvalidOperationException) { /* non-owner: disable republish UI */ }","preventionTips":["Load the owner's license before any republish operation","Disable republish controls when AllowOwner is absent","Prefer creating a new document over republishing when not the owner"],"tags":["rights-management","permissions","owner","republish"],"backgroundTag":"permission-denied","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}