{"record":{"id":"4b0c30eebecb92cd","repo":"dotnet/wpf","slug":"invalidlicense-rightsmanagementfailurecode","errorCode":"InvalidLicense","errorMessage":"RightsManagementFailureCode.InvalidLicense","messagePattern":"RightsManagementFailureCode\\.InvalidLicense","errorType":"error_code","errorClass":"MS.Internal.Security.RightsManagement.RightsManagementException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/IssuanceLicense.cs","lineNumber":614,"sourceCode":"            }\n            else if (string.Equals(userIdTypeStr, AuthenticationType.Internal.ToString(), StringComparison.OrdinalIgnoreCase))\n            {\n                // internal anyone user \n                if (ContentUser.CompareToAnyone(userIdStr))\n                {\n                    return ContentUser.AnyoneUser;\n                }\n                else if (ContentUser.CompareToOwner(userIdStr))\n                {\n                    return ContentUser.OwnerUser;\n                }\n            }\n            else if (string.Equals(userIdTypeStr, UnspecifiedAuthenticationType, StringComparison.OrdinalIgnoreCase))\n            {\n                return new ContentUser(userNameStr, AuthenticationType.WindowsPassport);\n            }\n\n            throw new RightsManagementException(RightsManagementFailureCode.InvalidLicense);\n        }\n\n        private ContentUser GetIssuanceLicenseUser(int index, out SafeRightsManagementPubHandle userHandle)\n        {\n            Invariant.Assert(index >= 0);\n\n            int hr = SafeNativeMethods.DRMGetUsers(\n                _issuanceLicenseHandle, (uint)index, out userHandle);\n\n            // there is a special code indication end of the enumeration \n            if (hr == (int)RightsManagementFailureCode.NoMoreData)\n            {\n                userHandle = null;\n                return null;\n            }\n\n            // check for errors\n            Errors.ThrowOnErrorCode(hr);","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/IssuanceLicense.cs#L596-L632","documentation":"GetUserFromHandle parses an issuance-license user handle (name + ID-type strings from the native license). If the userIdType string does not match any supported authentication type (Windows, Passport, etc., including the 'Unspecified' fallback), the license's user section violates the expected schema and the library throws RightsManagementException with FailureCode.InvalidLicense.","triggerScenarios":"Reading user entries from an issuance license (via GetIssuanceLicenseUser / GetIssuanceLicenseInfo) whose ID-TYPE attribute is an unrecognized authentication-type string.","commonSituations":"Licenses issued by non-WPF tools with custom or localized ID-TYPE values; corrupted or hand-edited license XML; newer license formats using types this framework version doesn't know.","solutions":["Verify the license XML user entries use supported ID-TYPE values (Windows, Passport, or unspecified).","Re-issue the license with a standard publisher/AuthenticationType.","Upgrade to a framework version recognizing the newer authentication types.","Catch RightsManagementException(FailureCode.InvalidLicense) around UnsignedPublishLicense parsing."],"exampleFix":"// before\nvar ulp = new UnsignedPublishLicense(rawLicenseXml); // throws InvalidLicense on unknown ID-TYPE\n\n// after: validate user types first\nvar doc = XDocument.Parse(rawLicenseXml);\nbool ok = doc.Descendants(\"IDTYPE\").All(e =>\n    e.Value.Equals(\"Windows\", StringComparison.OrdinalIgnoreCase) ||\n    e.Value.Equals(\"Passport\", StringComparison.OrdinalIgnoreCase));\nif (!ok) throw new InvalidDataException(\"License has unsupported user ID-TYPE.\");\nvar ulp = new UnsignedPublishLicense(rawLicenseXml);","handlingStrategy":"validation","validationCode":"var allowed = new[]{\"Windows\",\"Passport\",\"Unspecified\"};\nforeach (var idtype in XDocument.Parse(licenseXml).Descendants(\"IDTYPE\"))\n    if (!allowed.Contains(idtype.Value, StringComparer.OrdinalIgnoreCase))\n        throw new InvalidDataException($\"Unsupported user ID-TYPE: {idtype.Value}\");","typeGuard":"static bool IsSupportedAuthType(string idType) =>\n    idType != null &&\n    (idType.Equals(\"Windows\", StringComparison.OrdinalIgnoreCase) ||\n     idType.Equals(\"Passport\", StringComparison.OrdinalIgnoreCase) ||\n     idType.Equals(\"Unspecified\", StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"catch (RightsManagementException ex) when (ex.FailureCode == RightsManagementFailureCode.InvalidLicense) { /* re-issue or upgrade the license */ }","preventionTips":["Normalize user authentication types to supported values when authoring licenses.","Validate license user sections before constructing UnsignedPublishLicense.","Upgrade the framework when consuming licenses from newer issuers."],"tags":["rights-management","drm","license","authentication","schema"],"backgroundTag":"invalid-enum-value","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"}