DEV Community

Suat Can Geyik
Suat Can Geyik

Posted on Edited on AI-assisted

Understand Microsoft Entra ID

When my AZ-104 plan reached Microsoft Entra ID, I expected "Active Directory in the cloud". It isn't, and this module explains why. I work with Active Directory every day: domain controllers, PowerShell, group memberships, password resets.

I studied the module, then turned it into two lab tasks in my own tenant, written up like real work tickets: one change request in Entra ID, and one health check of the domain controller I run on an Azure VM. Here's what I learned, what broke, and how I'd use it day to day.

Understand Microsoft Entra ID - Training | Microsoft Learn

This module equips learners to describe Microsoft Entra ID - a cloud-based identity and access management service. They'll compare it with AD DS, understand its role as a directory for cloud services, and learn about its security features. They'll also learn about Microsoft Entra Domain Services.

learn.microsoft.com

5 key takeaways

  • Entra ID is not AD DS in the cloud: no OUs, no GPOs, no LDAP, no Kerberos. It speaks HTTPS and tokens.
  • A subscription trusts exactly one tenant; one tenant can serve many subscriptions.
  • Every app has two objects: the application (the definition) and a service principal (its instance in each tenant).
  • P1 controls who gets in and from where (Conditional Access, dynamic groups, group-based licensing). P2 reacts to risk and limits standing admin rights (ID Protection, PIM).
  • An error page that says 401 doesn't always mean "not signed in". Read the sign-in log before you guess.

Key points from the module

Entra ID vs AD DS. The clearest way I found to hold the difference: AD DS was built for one trusted network, Entra ID was built for the internet. Everything else follows from that.

AD DS Microsoft Entra ID
Runs on Windows Server domain controllers you own A Microsoft-managed cloud service (PaaS)
Structure Hierarchical: domains, OUs Flat: users, groups, devices
Query / manage LDAP REST (Microsoft Graph) over HTTPS
Sign-in protocols Kerberos, NTLM SAML, WS-Federation, OpenID Connect, OAuth
Policy Group Policy linked to OUs No GPOs: Intune, Conditional Access, group-based assignment
Devices Computer objects (domain join) Device objects (Entra join)
Between orgs Domain and forest trusts Federation, B2B guests

Running a domain controller on an Azure VM (like my DC01) doesn't use Entra ID at all. It's still AD DS, just on IaaS.

Tenant and subscription. A tenant is one Entra ID instance: the security boundary that holds users, groups and apps. When you create an Azure subscription with a personal Microsoft account, you get a new tenant called Default Directory, which is exactly what my lab runs in. A subscription trusts one tenant at a time, and Azure role assignments point at principals in that tenant. That's why moving a subscription to another tenant removes its role assignments: the old users no longer exist there.

Application vs service principal. Registering an app creates an application object in its home tenant (redirect URIs, secrets, requested permissions) and a service principal, which is the app's instance in each tenant that uses it. Role assignments, consent and "who can sign in" are set on the service principal. Managed identities are service principals too.

Licences.

Plan What it adds (as the module and current docs describe it)
Free Comes with every Azure subscription and Microsoft 365: users, groups, basic SSO, security defaults
P1 Conditional Access, dynamic groups, group-based licensing, SSPR with password writeback to on-prem AD, advanced security reports, Entra Connect Health
P2 Everything in P1, plus ID Protection (user and sign-in risk) and Privileged Identity Management (just-in-time admin)

Entra Domain Services. A managed domain: domain join, Group Policy, Kerberos, NTLM and LDAP, with Microsoft running the domain controllers. It's meant for older apps that need those protocols in Azure without a VPN back to on-prem DCs. You give up schema extensions, Domain Admins and most GPO flexibility. One correction to the module: it says Domain Services runs as part of P1 or P2. Microsoft now prices it as its own service, billed per hour by SKU, so check the pricing page.

Lab 1: stop every user from registering apps (a change request)

The request: "Only admins and approved developers should register applications." By default, every member user in a new tenant can create app registrations. Each one can hold secrets and ask for permissions, which makes it a common shadow-IT and consent-phishing risk.

My setup: a Mac with PowerShell 7, the Az module, and the Microsoft Graph PowerShell SDK (only the sub-modules I needed, all the same version):

Install-Module Microsoft.Graph.Authentication, Microsoft.Graph.Identity.SignIns, `
  Microsoft.Graph.Users, Microsoft.Graph.Groups, Microsoft.Graph.Identity.DirectoryManagement `
  -Scope CurrentUser -Repository PSGallery
Enter fullscreen mode Exit fullscreen mode

1. Record the "before" value

A change needs a rollback value, so I read it first. The setting lives in the tenant's authorization policy:

$tid = (Get-AzContext).Tenant.Id
Connect-MgGraph -TenantId $tid -Scopes "Policy.Read.All","Policy.ReadWrite.Authorization" -NoWelcome

(Get-MgPolicyAuthorizationPolicy).DefaultUserRolePermissions | Format-List
Enter fullscreen mode Exit fullscreen mode
AllowedToCreateApps                      : True
AllowedToCreateSecurityGroups            : True
AllowedToCreateTenants                   : True
AllowedToReadOtherUsers                  : True
Enter fullscreen mode Exit fullscreen mode

AllowedToCreateApps is what the portal calls Users can register applications. Rollback value: True.

2. Change it and prove it

Update-MgPolicyAuthorizationPolicy -DefaultUserRolePermissions @{ AllowedToCreateApps = $false }

(Get-MgPolicyAuthorizationPolicy).DefaultUserRolePermissions |
  Format-List AllowedToCreateApps, AllowedToCreateSecurityGroups, AllowedToCreateTenants
Enter fullscreen mode Exit fullscreen mode
AllowedToCreateApps           : False
AllowedToCreateSecurityGroups : True
AllowedToCreateTenants        : True
Enter fullscreen mode Exit fullscreen mode

Only the one property changed. The portal agreed: Users → User settings → Users can register applications = No.

3. Test it as a normal user

Admins aren't affected by this setting, so I created a test user with no roles. The temporary password never appears in the command or the transcript:

$dom = (Get-AzTenant -TenantId $tid).DefaultDomain
$pw  = Read-Host "Temporary password for lab-dev01" -AsSecureString
$plain = [System.Net.NetworkCredential]::new('', $pw).Password

New-MgUser -DisplayName "Lab Dev 01" -UserPrincipalName "lab-dev01@$dom" -MailNickname "lab-dev01" `
  -AccountEnabled -UsageLocation TR -Department "LAB - test user, delete after lab" `
  -PasswordProfile @{ Password = $plain; ForceChangePasswordNextSignIn = $true }

Remove-Variable plain
Enter fullscreen mode Exit fullscreen mode

Then I signed in as that user in a private window: forced password change, MFA registration, then App registrations.

4. The twist: "You do not have access, Error code 401"

The page said You do not have access… Error code 401… Error loading your content. My first guess was a stale token after the MFA registration. That guess was wrong, and I'm keeping it in the post because it's the most useful part of the lab.

The user's sign-in log told the real story:

03:11  Azure Portal            Interrupted  50055   (password expired: forced change)
03:15  Microsoft Authenticator Failure      50126   (wrong password during MFA setup, ×3)
03:16  Azure Portal            Interrupted  50140   ("stay signed in?" prompt)
03:16  Azure Portal            Success      0
Enter fullscreen mode Exit fullscreen mode

The sign-in succeeded. A clean retry in the Entra admin center showed that the app registrations list opened fine, and only New registration was refused. So it wasn't an authentication problem. It was authorization, and it was my own change working as designed. The "401" on the error page was a red herring.

5. Fix it like a ticket: least privilege, not rollback

The real request behind the ticket is "this developer needs to register an app". Setting the tenant back to True would reopen it for everyone. The least-privilege fix is the Application Developer role for that one person: it lets them register apps even when the setting is No.

Connect-MgGraph -TenantId $tid -Scopes "RoleManagement.ReadWrite.Directory","User.Read.All" -NoWelcome
$u    = Get-MgUser -UserId "lab-dev01@$dom"
$role = Get-MgRoleManagementDirectoryRoleDefinition -Filter "displayName eq 'Application Developer'"
Enter fullscreen mode Exit fullscreen mode
Get-MgRoleManagementDirectoryRoleDefinition: The term 'Get-MgRoleManagementDirectoryRoleDefinition'
is not recognized as a name of a cmdlet, function, script file, or executable program.
Enter fullscreen mode Exit fullscreen mode

A second, smaller twist: the role cmdlets live in Microsoft.Graph.Identity.Governance, which I hadn't installed. Installing it at the same version fixed it:

Install-Module Microsoft.Graph.Identity.Governance -RequiredVersion 2.41.2 -Scope CurrentUser -Repository PSGallery

$role = Get-MgRoleManagementDirectoryRoleDefinition -Filter "displayName eq 'Application Developer'"
New-MgRoleManagementDirectoryRoleAssignment -PrincipalId $u.Id -RoleDefinitionId $role.Id -DirectoryScopeId "/" | Out-Null
Enter fullscreen mode Exit fullscreen mode
Role                  Scope
----                  -----
Application Developer /
Enter fullscreen mode Exit fullscreen mode

The test user registered test-app-b (single tenant) without errors. From the admin side I checked what had actually been created:

DisplayName SignInAudience CreatedDateTime
test-app-b  AzureADMyOrg   28.11.2026 23:36:52
owner: lab-dev01@<tenant>.onmicrosoft.com
service principal: test-app-b  (ServicePrincipalType: Application)
Enter fullscreen mode Exit fullscreen mode

One registration, two objects: the application and its service principal. That's unit 2 of the module, seen for real.

6. Clean up and prove it's gone

Remove-MgApplication -ApplicationId $app.Id
$ra = Get-MgRoleManagementDirectoryRoleAssignment -Filter "principalId eq '$($u.Id)'"
Remove-MgRoleManagementDirectoryRoleAssignment -UnifiedRoleAssignmentId $ra.Id
Enter fullscreen mode Exit fullscreen mode
App: none
SP: none
Roles on lab-dev01: 0
AllowedToCreateApps: False
Enter fullscreen mode Exit fullscreen mode

The app is soft-deleted (restorable for 30 days), the role is gone, and the tenant setting stays No. I kept the test user for the next module.

Lab 2: is my domain controller on Azure set up the way Microsoft recommends? (an incident)

The module says it in one line: a DC on an Azure VM should keep its database, logs and SYSVOL on a separate data disk with host caching set to None, never on C:. I'd never checked my own DC01, so I did, read-only.

1. Azure side: disks and caching

$vm = Get-AzVM | Where-Object Name -eq 'DC01'
$vm.StorageProfile.OsDisk    | Select-Object Name, Caching
$vm.StorageProfile.DataDisks | Select-Object Lun, Name, Caching
Enter fullscreen mode Exit fullscreen mode
Name                Caching
DC01_OsDisk_1_...   ReadWrite
(no data disks)
Enter fullscreen mode Exit fullscreen mode

2. DC side: where AD really keeps its data

Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\NTDS\Parameters' |
  Select-Object 'DSA Database file','Database log files path'
Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters' | Select-Object SysVol
Get-WinEvent -FilterHashtable @{LogName='Directory Service'; Id=2170} -MaxEvents 10 |
  Select-Object TimeCreated, Id
Get-VM | Select-Object Name, State, AutomaticStartAction
Enter fullscreen mode Exit fullscreen mode
C:\Windows\NTDS\ntds.dit   C:\Windows\NTDS
SysVol : C:\Windows\SYSVOL\sysvol

11/29/2026 12:37:09 AM 2170
11/13/2026  7:47:37 PM 2170
11/11/2026 12:31:36 AM 2170
... 7 more

VM-1   Off   StartIfRunning
VM-2   Off   StartIfRunning
Enter fullscreen mode Exit fullscreen mode

Four findings, one after another:

  1. Everything is on C:, the OS disk with ReadWrite caching. Not what Microsoft recommends.
  2. Event 2170 after every start. My lab VM is deallocated every night to save money (auto-shutdown). Each start from deallocation looks to Windows like a VM restore, so the VM-GenerationID safeguard fires: the DC resets its invocation ID, throws away its RID pool and marks SYSVOL as non-authoritative. That protects against USN rollback, and it's doing its job, but it happens every single day.
  3. DC02 was off. DC02 is a Hyper-V VM on DC01. StartIfRunning only restarts guests that were running when the host went down. DC02 had been off once, so it stayed off.
  4. Replication had been broken for about three weeks.
repadmin /replsummary
Source DSA   largest delta      fails/total  error
 DC02        20d.21h:56m:00s    5 / 5        (8524) The DSA operation is unable to proceed
                                                    because of a DNS lookup failure.
Enter fullscreen mode Exit fullscreen mode

The interesting part: dcdiag passed SysVolCheck and NetLogons the whole time. SYSVOL was still waiting for a partner (DFSR event 4614 with no 4604 after it), but dcdiag alone didn't show that.

3. The fix (the part I could do safely)

I started DC02 from Hyper-V Manager. Within two minutes DFSR logged 4604 (SYSVOL initialized), and ten minutes later:

repadmin /replsummary
Source DSA   largest delta   fails/total
 DC01        08m:17s         0 / 5
 DC02        05m:00s         0 / 5
Enter fullscreen mode Exit fullscreen mode

All five partitions replicated, and dcdiag /s:DC02 /test:replications passed. It showed four "Expected notification link is missing" latency warnings, which dcdiag itself says fix themselves on the next periodic sync.

Moving NTDS and SYSVOL to a data disk is a real change on a domain controller, so I didn't do it in an audit. I wrote it up as two change requests instead: (1) a data disk with caching None, ideally by building a new DC with -DatabasePath, -LogPath and -SysvolPath on that disk, and (2) a decision about nightly deallocation of DCs.

What I didn't do (yet): group-based licensing

My third planned task was assigning a licence through a dynamic group (a jobTitle + usageLocation rule). Both dynamic groups and group-based licensing need Entra ID P1, and my lab tenant is on Free. The P2 trial lasts 30 days and is available once per tenant, so I'm saving it for the next module, where it also covers SSPR and Conditional Access.

What surprised me

  • The "401" wasn't about authentication. The sign-in log showed Success. The portal error page code pointed me the wrong way.
  • "Users can register applications" isn't the only door. Right below it, the portal now has a separate Users can register agent identity blueprints toggle, still set to Yes.
  • Entra changes don't show in the Azure Activity Log. My lab script exported 0 events for the session where I changed the tenant setting. Directory changes go to the Entra audit log; the proof is a Graph GET.
  • Disconnect-MgGraph prints your tenant ID. It returns the context it just closed. Pipe it to Out-Null if you record transcripts.
  • Cost-saving and domain controllers pull in opposite directions. Nightly deallocation keeps my bill down, and makes my DC reset its safeguards every morning.
  • The module is partly dated. The Domain Services licensing line, and some plan names, no longer match current Microsoft docs. Check the pricing pages.

Does it cost money?

Action Cost
Entra ID Free tenant, users, the tenant setting, roles, app registrations Free
Graph PowerShell, sign-in logs (Free keeps 7 days) Free
Dynamic groups, group-based licensing, Conditional Access Entra ID P1 (per user, per month), or the one-time 30-day P2 trial
DC01 running for the audit Normal VM compute while it runs; deallocated straight after
A data disk for AD (the proposed fix) A small managed disk, billed per month by size
Entra Domain Services Its own hourly charge by SKU, not included in P1 or P2

Lab 1 cost nothing. Lab 2 cost about an hour of compute.

Daily use in real life

  • Tenant hardening on day one. Review User settings in a new tenant: app registrations, tenant creation, security group creation, agent identity blueprints. Record the before values in the change ticket.
  • Least privilege for exceptions. When one person needs something the defaults block, give them a scoped role (with PIM if you have P2), not a tenant-wide rollback.
  • Troubleshooting sign-in tickets. Open the user's sign-in logs before anything else. Error codes like 50055, 50126 and 50140 tell you whether it's the password, MFA or a prompt, and "Success + still denied" means a permissions question.
  • Knowing which directory an app needs. "We support SAML/OIDC" means an Entra enterprise app. "We need LDAP binds" means AD DS or Entra Domain Services.
  • Health checks for DCs in Azure. Check disk layout and caching, Event 2170, DFSR 4614/4604, and repadmin /replsummary from both sides. Don't trust a single green dcdiag.
  • Never leave a DC off for long. Alert well before the 60-day DFSR offline limit and the 180-day tombstone lifetime.

Exam tips (AZ-104)

This module is the background for Manage Microsoft Entra users and groups in the Manage Azure identities and governance domain, and maps directly to Manage licenses in Microsoft Entra ID. I passed the module assessment with 7/9. The two I missed are the first two tips.

  • Pick the lowest plan that has the feature. Advanced security reports and alerts are P1, not P2.
  • "Bridge on-premises identity stores" in a P1/P2 feature list means Microsoft Identity Manager, not PIM. PIM is P2 just-in-time admin.
  • Conditional Access, dynamic groups, group-based licensing, SSPR writeback: P1. Risk-based policies and PIM: P2.
  • "Use LDAP against Entra ID" and "create an OU in Entra ID" are always wrong answers.
  • A subscription trusts one tenant; moving it to another tenant removes its role assignments.
  • Choosing a directory: Entra ID alone for web apps; Entra Domain Services for a managed domain without schema changes; AD DS on VMs for full control.
  • A user needs a usage location before a licence can be assigned.

Next: users, groups and guests

The next module, Create, configure, and manage identities, picks up where this one stopped: dynamic groups, group-based licensing with the P2 trial, and inviting an external guest to compare Member and Guest users.

Resources


Written from my own lab notes and command transcripts, with help from an AI assistant for drafting and structure. The commands and outputs are from my lab tenant; IDs, domain names and IP addresses are removed. I checked the facts against Microsoft Learn and Docs before publishing.

Top comments (0)