Fix internal admin losing SUPER during customized plan provisioning#9717
Fix internal admin losing SUPER during customized plan provisioning#9717darjoo wants to merge 1 commit 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 <223556219+Copilot@users.noreply.github.com>
|
Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234' |
| local procedure IsUserInternalAdmin(SecurityID: Guid): Boolean | ||
| var | ||
| PlanIds: Codeunit "Plan Ids"; | ||
| begin |
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
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 #
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.