Cloud Identity Fundamentals
Azure Active Directory (now Microsoft Entra ID) is Microsoft's cloud-based identity and access management service. Unlike on-premises AD, which uses LDAP and Kerberos, Entra ID is built on REST APIs and modern authentication protocols (OAuth 2.0, OIDC, SAML).
The core hierarchy:
- Tenant — A dedicated instance of Entra ID. Each organization gets one tenant, identified by a unique tenant ID and a
*.onmicrosoft.com domain.
- Directory — The identity store within the tenant containing users, groups, applications, and devices.
- Subscription — A billing and resource boundary for Azure services. Subscriptions trust a single tenant for authentication.
| Aspect |
On-Premises AD (AD DS) |
Azure AD / Entra ID |
| Protocol |
LDAP, Kerberos, NTLM |
OAuth 2.0, OpenID Connect, SAML |
| Auth Method |
Domain-join, GPO, service tickets |
Token-based, Conditional Access, MFA |
| Device Management |
Group Policy, SCCM |
Intune, Azure AD Join, compliance policies |
| Structure |
Forests, Domains, OUs |
Flat tenant, no OU hierarchy (use Administrative Units) |
| Admin Portal |
ADUC, ADSI Edit, PowerShell |
Entra admin center, Azure CLI, Graph API, PowerShell |
Azure AD Connect
Azure AD Connect (and its successor, Azure AD Connect Cloud Sync) bridges on-premises Active Directory with Entra ID, creating a hybrid identity. Users authenticate with the same credentials across on-prem and cloud resources.
Three authentication methods for hybrid identity:
- Password Hash Sync (PHS) — A hash of the on-prem password hash is synced to Entra ID. Users authenticate directly against the cloud. Simplest to deploy; enables leaked credential detection.
- Pass-Through Authentication (PTA) — Authentication requests are forwarded to on-prem agents that validate against AD DS. Passwords never leave the on-prem boundary. Requires agents on domain-joined servers.
- Federation (AD FS) — All authentication is redirected to on-prem AD FS servers. Maximum control over sign-in experience, but highest complexity and maintenance burden.
# Trigger a delta sync cycle (sync recent changes)
Start-ADSyncSyncCycle -PolicyType Delta
# Trigger a full sync cycle (re-sync everything)
Start-ADSyncSyncCycle -PolicyType Initial
# Check current sync status
Get-ADSyncScheduler
# View sync errors
Get-ADSyncCSObject -ConnectorName "contoso.com" |
Where-Object {$_.HasSyncError -eq $true} |
Select DistinguishedName, SyncError
# Review sync rules and their precedence
Get-ADSyncRule | Select Name, Direction, Precedence,
SourceObjectType, TargetObjectType |
Sort Precedence | Format-Table
Source of Authority
When Azure AD Connect is active, on-premises AD is the source of authority for synced objects. Changes to synced attributes (displayName, department, manager) must be made on-premises — edits made in the Entra portal will be overwritten on the next sync cycle. Cloud-only attributes (like Conditional Access assignments) are managed exclusively in Entra ID.
Conditional Access
Conditional Access policies are the central policy engine of Entra ID. They evaluate signals (who, where, what device, what app, risk level) and enforce access decisions (allow, block, require MFA, require compliant device) in real time during sign-in.
Every policy has two parts:
- Assignments — When does this policy apply? Define users/groups, target apps, and conditions (location, device platform, sign-in risk, client app type).
- Access Controls — What happens when the conditions are met? Grant access (with requirements like MFA, compliant device, hybrid Azure AD join) or block access entirely. Session controls can limit download/upload, enforce app restrictions, or set sign-in frequency.
Common policy patterns:
Require MFA from Untrusted Networks
Assignments:
Users: All users
Apps: All cloud apps
Conditions:
Locations: Exclude — Named: "Corporate Network"
Access Controls:
Grant: Require multi-factor authentication
Users on corporate IPs skip MFA; all others must complete a second factor.
Block Legacy Authentication
Assignments:
Users: All users
Apps: All cloud apps
Conditions:
Client apps: Exchange ActiveSync, Other clients
Access Controls:
Block access
Prevent IMAP, POP3, SMTP AUTH, and older Office clients that cannot support MFA.
Require Compliant Devices
Assignments:
Users: All users (exclude break-glass accounts)
Apps: Office 365
Conditions:
Device platforms: Windows, iOS, Android
Access Controls:
Grant: Require device to be marked as compliant
Only Intune-enrolled devices meeting compliance policies can access Office 365.
Risk-Based MFA
Assignments:
Users: All users
Apps: All cloud apps
Conditions:
Sign-in risk: Medium and above
Access Controls:
Grant: Require multi-factor authentication
Entra ID Identity Protection triggers MFA when anomalous sign-in behavior is detected.
Break-Glass Accounts
Always exclude at least two emergency access (break-glass) accounts from all Conditional Access policies. These are cloud-only accounts with Global Administrator role, long random passwords, and no MFA requirement. Store credentials in a physical safe. Without them, a misconfigured Conditional Access policy can lock every admin out of the tenant permanently.
App Registrations & Service Principals
In Entra ID, applications have a two-object model that separates the definition of an app from its instantiation in a tenant:
- App Registration — The global definition of the application (client ID, redirect URIs, API permissions, certificates/secrets). Lives in the home tenant. Think of it as the "class definition."
- Service Principal — The local instance of an app within a specific tenant. Created automatically when an app is consented to or provisioned. Think of it as the "object instance." Enterprise applications in the Entra portal are service principals.
- Managed Identity — A special type of service principal whose credentials are managed entirely by Azure. No secrets to rotate.
# Create an app registration
az ad app create --display-name "Contoso Automation" \
--sign-in-audience "AzureADMyOrg"
# Create a service principal with RBAC role assignment
az ad sp create-for-rbac \
--name "sp-contoso-automation" \
--role "Contributor" \
--scopes "/subscriptions/{subscription-id}/resourceGroups/rg-production"
# List app registrations
az ad app list --display-name "Contoso" --output table
# Add a client secret (rotate before expiry!)
az ad app credential reset \
--id {app-id} \
--append \
--display-name "automation-secret-2025" \
--years 1
Managed Identities
Managed Identities eliminate the need for developers to manage credentials. Azure automatically provisions and rotates the identity's certificates behind the scenes.
| Type |
Lifecycle |
Sharing |
Best For |
| System-Assigned |
Tied to the resource; deleted when the resource is deleted |
One-to-one (cannot be shared) |
Single-resource workloads (a VM accessing Key Vault, an App Service calling SQL) |
| User-Assigned |
Independent resource; persists until explicitly deleted |
One-to-many (assigned to multiple resources) |
Shared identity across VMs, Functions, and containers in the same workload |
# Enable system-assigned managed identity on a VM
az vm identity assign --name vm-web01 --resource-group rg-production
# Create a user-assigned managed identity
az identity create --name mi-shared-workload --resource-group rg-production
# Assign the user-assigned identity to a VM
az vm identity assign --name vm-web01 --resource-group rg-production \
--identities mi-shared-workload
# Grant the managed identity access to Key Vault
az keyvault set-policy --name kv-production \
--object-id $(az vm identity show --name vm-web01 -g rg-production \
--query principalId -o tsv) \
--secret-permissions get list
No Secrets to Rotate
Managed identities obtain tokens from the Azure Instance Metadata Service (IMDS) at http://169.254.169.254/metadata/identity/oauth2/token. The credentials never appear in code, config files, or environment variables. This eliminates an entire class of credential-leak vulnerabilities.
Microsoft Graph API
The Microsoft Graph API is the unified REST endpoint for interacting with all Microsoft cloud services, including Entra ID. All identity operations — managing users, groups, applications, and policies — flow through Graph.
# List users in the Engineering department
GET https://graph.microsoft.com/v1.0/users?$filter=department eq 'Engineering'
&$select=displayName,userPrincipalName,jobTitle
&$orderby=displayName
# Get a specific user's group memberships
GET https://graph.microsoft.com/v1.0/users/{user-id}/memberOf
?$select=displayName,groupTypes
# List all enterprise applications (service principals)
GET https://graph.microsoft.com/v1.0/servicePrincipals
?$filter=tags/any(t:t eq 'WindowsAzureActiveDirectoryIntegratedApp')
&$select=displayName,appId,servicePrincipalType
# Microsoft Graph PowerShell SDK
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All"
# Get all users
Get-MgUser -All -Property DisplayName, UserPrincipalName, Department |
Format-Table
# Create a new security group
New-MgGroup -DisplayName "SG-Engineering-Leads" `
-MailEnabled:$false -MailNickname "sg-eng-leads" `
-SecurityEnabled:$true `
-Description "Engineering leadership team"
# Add a member to a group
New-MgGroupMember -GroupId {group-id} `
-DirectoryObjectId {user-id}
# List app registrations with expiring credentials
Get-MgApplication -All | ForEach-Object {
$app = $_
$_.PasswordCredentials | Where-Object {
$_.EndDateTime -lt (Get-Date).AddDays(30)
} | Select @{N='App';E={$app.DisplayName}},
@{N='SecretName';E={$_.DisplayName}},
@{N='Expires';E={$_.EndDateTime}}
} | Where-Object {$_} | Format-Table
B2B & B2C
Entra ID supports two models for external identity scenarios, each designed for a fundamentally different audience:
| Aspect |
B2B (Business-to-Business) |
B2C (Business-to-Consumer) |
| Audience |
Partners, vendors, contractors with their own organizational identity |
Customers and end users (public-facing) |
| Identity Source |
Guest user's home tenant, Google, Microsoft accounts |
Local accounts, social IdPs (Google, Facebook, Apple), custom OIDC |
| Tenant |
Guests appear in your tenant's directory as external users |
Separate B2C tenant with its own user directory |
| Customization |
Limited — uses standard Entra sign-in experience |
Fully customizable sign-up/sign-in flows and UI branding |
| Scale |
Hundreds to thousands of external collaborators |
Millions of consumer accounts |
# Invite a B2B guest user
New-MgInvitation -InvitedUserEmailAddress "partner@fabrikam.com" `
-InviteRedirectUrl "https://myapp.contoso.com" `
-SendInvitationMessage:$true
# List all guest users in the tenant
Get-MgUser -Filter "userType eq 'Guest'" -All |
Select DisplayName, Mail, CreatedDateTime |
Sort CreatedDateTime -Descending
# Remove stale guest accounts (no sign-in for 90 days)
Get-MgUser -Filter "userType eq 'Guest'" -All `
-Property DisplayName, SignInActivity |
Where-Object {
$_.SignInActivity.LastSignInDateTime -lt (Get-Date).AddDays(-90)
} | Select DisplayName, @{
N='LastSignIn'; E={$_.SignInActivity.LastSignInDateTime}
}
Guest Account Governance
B2B guest users accumulate over time and often retain access long after a collaboration ends. Use Entra ID Access Reviews to periodically require guest sponsors to re-confirm that access is still needed. Configure automatic removal of guests who are denied or not reviewed. Without governance, guest accounts become a significant attack surface.