Fix internal admin losing SUPER during customized plan provisioning#9717
Open
darjoo wants to merge 2 commits into
Open
Fix internal admin losing SUPER during customized plan provisioning#9717darjoo wants to merge 2 commits into
darjoo wants to merge 2 commits into
Conversation
Internal tenant administrators (Global Admin / D365 Admin) lost SUPER when provisioned for the first time with a customized license plan that omits SUPER. In codeunit 9018 "Azure AD Plan Impl.", AddNewlyAssignedUserPlans only applied the admin exemption on the default (non-customized) plan branch; the customized branch set ShouldRemoveSuper solely from whether the configuration contained SUPER, bypassing the admin check. Add a local IsUserInternalAdmin helper (Global Admin, D365 Admin, BC Admin plans only, excluding delegated partner roles) and guard the customized branch with it, so internal admins keep SUPER even when the custom mapping omits it. Ordinary users still lose SUPER, and delegated admins are intentionally not exempted here since their SUPER is governed separately in AssignPlanToUserWithDelegatedRole. Add tests covering internal admin retain, D365 admin retain, non-admin remove, customized-with-SUPER retain, delegated admin remove, and the existing-user path. Co-authored-by: Copilot App <[email protected]>
| local procedure IsUserInternalAdmin(SecurityID: Guid): Boolean | ||
| var | ||
| PlanIds: Codeunit "Plan Ids"; | ||
| begin |
Contributor
There was a problem hiding this comment.
IsUserInternalAdmin() now has three admin-plan branches (Global Admin, D365 Admin, BC Admin), but the new regression tests only exercise the Global Admin and D365 Admin paths (TestInternalAdminKeepsSuperWhenCustomizedPlanOmitsSuper, TestD365AdminKeepsSuperWhenCustomizedPlanOmitsSuper). The BC Admin branch that gates the SUPER-retention behavior is untested. Add an equivalent test using PlanIds.GetBCAdminPlanId() to cover that branch.
Agent judgement — not directly backed by a BCQuality knowledge article.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.15.4
…on tests The Premium plan already has a default Plan Configuration record created at app install, so AddConfiguration (a plain Insert) failed with a duplicate primary key. Clear plan configurations first, matching the pattern used by the Azure AD Plan system application tests. Co-authored-by: Copilot App <[email protected]>
onbuyuka
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Internal tenant administrators (Global Admin / Dynamics 365 Admin) lost their SUPER permission set when they were provisioned for the first time and their license plan configuration was customized without explicitly including SUPER. This could lock the first admin out of an environment right after customizing a plan.
The root cause is in codeunit 9018
"Azure AD Plan Impl.", procedureAddNewlyAssignedUserPlans. The internal-admin exemption was only applied on the default (non-customized) plan branch:When any assigned plan was customized and omitted SUPER, the admin check was skipped entirely and SUPER was removed.
The fix adds a local
IsUserInternalAdminhelper (Global Admin, D365 Admin, and BC Admin plans only) and guards the customized branch with it:Key decisions:
AssignPlanToUserWithDelegatedRole, soIsUserInternalAdmindeliberately excludes the delegated/helpdesk plans (unlike the pre-existingIsUserAdmin, which includes delegated admin).Linked work
Fixes AB#643970
How I validated this
What I tested and the outcome
Added six tests to
AzureADPlanModuleTest.codeunit.al(codeunit 139509) exercisingRefreshUserPlanAssignmentson a customized Premium plan:Default-plan behavior remains covered by the existing internal/D365/delegated admin tests.
Risk & compatibility
releases/24.xthroughreleases/28.xbranches are recommended.