{"record":{"id":"0504871bdfbcc185","repo":"dotnet/wpf","slug":"licenseacquisitionfailed","errorCode":"LicenseAcquisitionFailed","errorMessage":"RightsManagementFailureCode.LicenseAcquisitionFailed","messagePattern":"RightsManagementFailureCode\\.LicenseAcquisitionFailed","errorType":"error_code","errorClass":"MS.Internal.Security.RightsManagement.RightsManagementException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/ClientSession.cs","lineNumber":621,"sourceCode":"                    null,  // requested data is reserved and not used\n                    null, // custom data \n                    null, //no url required it will be taken from publish license   \n                    IntPtr.Zero);    // context \n\n                Errors.ThrowOnErrorCode(hr);\n\n                _callbackHandler.WaitForCompletion();         // it will throw a proper exception in a failure case            \n\n                // now we can enumerate the EUL Ids  again and try to find the new one \n                ArrayList newLicenseIds = EnumerateAllValuesOnSession\n                                        (licenseStorageSessionHandle, EnumerateLicenseFlags.EulLid);\n\n                int indexOfTheAcquiredLicense = FindNewEntryIndex(oldLicenseIds, newLicenseIds);\n\n                if (indexOfTheAcquiredLicense < 0)\n                {\n                    // we have failed to find the new license \n                    throw new RightsManagementException(RightsManagementFailureCode.LicenseAcquisitionFailed);\n                }\n\n                return new UseLicense(GetLicenseOnSession(\n                                                            licenseStorageSessionHandle,\n                                                            EnumerateLicenseFlags.Eul,\n                                                            indexOfTheAcquiredLicense));\n            }\n        }\n\n        private static int FindNewEntryIndex(ArrayList oldList, ArrayList newList)\n        {\n            Invariant.Assert((oldList != null) && (newList != null));\n\n            for (int i = 0; i < newList.Count; i++)\n            {\n                string newElement = (string)newList[i];\n                bool matchFound = false;\n","sourceCodeStart":603,"sourceCodeEnd":639,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/ClientSession.cs#L603-L639","documentation":"AcquireUseLicense asks the native DRM layer to acquire a use license, then diffs the license-ID list before and after acquisition. If no new license entry appears (FindNewEntryIndex returns < 0), the library concludes acquisition failed and throws RightsManagementException with failure code LicenseAcquisitionFailed.","triggerScenarios":"Calling CryptographicSession/ClientSession.AcquireUseLicense (e.g. via EncryptedPackageEnvelope opening, UseLicense acquisition in ProtectedDocument flows) where the server does not return a new EUL entry in the session license list.","commonSituations":"User is not granted any rights on the issuance license; RMS server unreachable or returned an error that the wrapper silently mapped to 'no new license'; clock skew or expired content making the server decline issuance; license already cached but with a changed ID scheme.","solutions":["Verify the user actually has rights granted in the issuance/publishing license (UseLicense content user and rights list).","Check network connectivity to the RMS cluster and confirm server event logs show the license-acquisition request.","Clear the user's DRM license store so stale cached IDs don't mask the newly acquired license, then retry.","Retry acquisition after fixing clock skew (Kerberos/RMS are time sensitive)."],"exampleFix":"// before\nUseLicense ul = session.AcquireUseLicense(secureEnvironment, contentUser);\n\n// after: check rights first and handle failure\nif (!unsignedPublishLicense.Grants.ContainsRightFor(contentUser))\n    throw new InvalidOperationException(\"User has no granted rights; use license acquisition will fail.\");\ntry { UseLicense ul = session.AcquireUseLicense(secureEnvironment, contentUser); }\ncatch (RightsManagementException ex) when (ex.FailureCode == RightsManagementFailureCode.LicenseAcquisitionFailed) { /* inform user */ }","handlingStrategy":"try-catch","validationCode":"if (!unsignedLicense.Grants.Any(g => g.ContentUser.Equals(user)))\n    throw new InvalidOperationException(\"User has no rights in the issuance license; use-license acquisition will fail.\");","typeGuard":null,"tryCatchPattern":"catch (RightsManagementException ex) when (ex.FailureCode == RightsManagementFailureCode.LicenseAcquisitionFailed) { /* check server reachability and granted rights, then retry */ }","preventionTips":["Confirm the content user has explicit rights in the publish license before acquiring.","Keep machine clocks synchronized (Kerberos/RMS time skew).","Clear stale license caches when IDs stop matching after upgrades."],"tags":["rights-management","drm","license-acquisition","server"],"backgroundTag":"license-acquisition-failed","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}