A hands-on lab exploring how to eliminate manual group management for finance staff, automate membership via dynamic rules, ensure contractors are strictly excluded and maintain appropriate administrative ownership.
1. Preparing Test Users
Dynamic rules rely on accurate user profile attributes. Before configuring the groups, the following user profile data was established:
| User | Department | Company Name | Role in Test |
| Adam | Finance | MrCloudSec | Valid employee |
| Raj | Finance | MrCloudSec | Contractor |
| Sam | Sales | MrCloudSec | Mover |
| Travis | (blank) | MrCloudSec | Joiner with incomplete data |
2. Dynamic Group Configuration & Rules
Finance Employees Group

To target active internal finance employees while excluding contractors, the rule syntax was configured as follows:
(user.department -eq "Finance") and (user.companyName -eq "MrCloudSec") and (user.accountEnabled -eq true)
Contractors Group
Since contractors can operate across different departments, the department filter is omitted. A negative match condition ensures users with a blank company name are not mistakenly categorized as contractors:
(user.companyName -ne "MrCloudSec") and (user.companyName -ne null)
3. Testing Scenarios & Verification
Scenario A: Mover (Sam from Sales to Finance)
Changing Sam’s department to Finance automatically added him to the Finance group; reverting his department removed him.
Scenario B: Contractors and General Memberships Overview
Verifying active direct members against the overall dynamic processing status[cite: 3].
Scenario C: Joiner with Incomplete Data (Travis)
Travis originally had no department set and belonged to no groups. Populating his department to Finance triggered automatic addition (top), and clearing it removed him again (bottom)[cite: 5].
Scenario D: Disabled Account (Adam)
Blocking Adam’s sign-in changed his status to accountEnabled = false[cite: 6, 7].
As a result, he stopped matching the dynamic rule condition, dropping the Finance group membership to zero until he was re-enabled[cite: 7].
4. Test Results Summary
| Scenario | Resulting Outcome |
| Adam (Enabled Finance employee) | Added to Finance[cite: 1, 3] |
| Raj (Finance contractor) | Placed in Contractors, excluded from Finance |
| Sam (Moved to Finance & back) | Added automatically, then removed |
| Travis (Department set & cleared) | Added automatically, then removed[cite: 5] |
| Adam (Blocked & re-enabled) | Removed upon disable, re-added upon re-enable[cite: 6, 7] |
5. Lessons & Key Recommendations
- Data Quality is Critical: Dynamic membership relies entirely on accurate profile data. Make Department and Company Name mandatory fields during onboarding.
- HR Integration: Source identity attributes directly from an authoritative HR system rather than manual entries.
- Account for Propagation Delays: Rule evaluations and membership updates take several minutes to apply; status marked as “Succeeded” indicates processing completion, not immediate matching.
- Audit Manual Overlaps: Dynamic rules do not remove legacy manual group memberships. Regularly review pre-existing assignments to eliminate leftover permissions.
- Licensing Requirements: Dynamic group features require Microsoft Entra ID P1 or higher for every unique user covered by a dynamic rule.