Skip to content

MusahIssah/Automated-AD-User-Provisioning-Lab.

Repository files navigation

Azure AD Hybrid Identity Lab

Project 5 — IT Support Portfolio Series

Built by Musah Issah | IT Support Specialist | U.S. Air Force Reserves | CompTIA Security+ | Active DoD Secret Clearance


Project Overview

This lab documents the complete build of a Microsoft Entra ID (Azure AD) Hybrid Identity environment — syncing 51 on-premises Active Directory users from a Windows Server 2022 domain controller running in Hyper-V to Microsoft Azure Entra ID, with MFA enforced via Security Defaults.

This is a real home lab build — including the errors I hit, how I diagnosed them, and how I fixed them. Every screenshot is genuine.


Architecture

┌─────────────────────────────────┐         ┌──────────────────────────────────┐
│     ON-PREMISES (Hyper-V)       │         │     MICROSOFT AZURE CLOUD        │
│                                 │         │                                  │
│  Windows Server 2022 (DC-01)    │         │  Microsoft Entra ID              │
│  Domain: company.org            │◄───────►│  Tenant: musahissahghoutlook     │
│  51 AD Users across OUs:        │  Entra  │  .onmicrosoft.com                │
│    - Finance                    │ Connect │                                  │
│    - IT-DEPT                    │  Sync   │  54 Users (51 synced + 3 cloud)  │
│    - Sales                      │         │  Security Defaults: ENABLED      │
│    - Users                      │         │  MFA: ENFORCED for all users     │
└─────────────────────────────────┘         └──────────────────────────────────┘

Technologies Used

Technology Purpose
Windows Server 2022 (Hyper-V) On-premises domain controller
Active Directory Domain Services Identity source — 51 users
Microsoft Entra Connect Sync v2.6.3.0 Hybrid identity sync engine
Microsoft Entra ID (Azure AD) Cloud identity platform
Microsoft Azure (Free Tier) Cloud infrastructure
PowerShell Automation and sync management
Security Defaults MFA enforcement for all users

What I Built — Phase by Phase

Phase 1 — Azure Tenant Setup

  • Created Microsoft Azure free account
  • Accessed Microsoft Entra admin center as Global Administrator
  • Added musahissahghoutlook.onmicrosoft.com as alternative UPN suffix in on-premises Active Directory Domains and Trusts
  • Updated test user arobinson UPN to arobinson@musahissahghoutlook.onmicrosoft.com
  • Verified domain status as Available in Entra ID Custom Domain Names

Screenshot: Azure Portal → Entra Admin Center → Domain Verified

Azure Portal Setup Entra Admin Center Domain Verified


Phase 2 — UPN Suffix Configuration

  • Opened Active Directory Domains and Trusts on DC-01
  • Added musahissahghoutlook.onmicrosoft.com as Alternative UPN Suffix
  • Updated user accounts in ADUC to use the new UPN suffix
  • This step is critical — without matching UPN suffixes, users sync but cannot sign into Azure

UPN Suffix Added User UPN Updated


Phase 3 — Microsoft Entra Connect Installation

  • Downloaded Entra Connect v2.6.3.0 from Entra Admin Center (not Microsoft Download Center — this changed in 2025)
  • Ran custom installation wizard selecting Password Hash Synchronization
  • Connected on-premises forest company.org — configured MSOL service account with replication permissions
  • Selected OUs: Finance, IT-DEPT, Sales, Users (excluded Builtin, Computers, Domain Controllers)
  • Clicked through UPN mismatch warning by selecting "Continue without matching all UPN suffixes"

Connect Directories Entra Sign-in Config Configuration Complete


Phase 4 — Sync Verification

  • Opened Synchronization Service Manager on DC-01
  • Confirmed 18 successful sync runs across both connectors
  • Verified 54 users in Entra ID → All Users with On-premises sync enabled: Yes
  • Users from all OUs synced successfully

Sync Service Manager Users Synced in Azure


Phase 5 — MFA Enforcement via Security Defaults

  • Enabled Security Defaults in Entra ID → Properties
  • Security Defaults enforces:
    • MFA required for all users on first cloud sign-in
    • MFA always required for admin accounts
    • Legacy authentication blocked
    • All users must register MFA within 14 days
  • Tested MFA enforcement: signed in as synced user arobinson — immediately prompted for MFA setup

MFA Prompt Working


Errors I Hit and How I Fixed Them

This section is the most valuable part of this repo. Real projects have real problems.

Error 1 — AADSTS50020: Wrong account type used in Entra Connect

What happened: When the Entra Connect wizard asked to connect to Microsoft Entra ID, I entered my personal Outlook account (musah.issah.gh@outlook.com). Got error: User account from identity provider 'live.com' does not exist in tenant 'Microsoft Services'

Root cause: Entra Connect requires a cloud-only Entra ID work account — not a personal Microsoft/Outlook account.

Fix: Created a dedicated admin account syncadmin@musahissahghoutlook.onmicrosoft.com with Global Administrator role directly inside the Entra tenant, then used that account in the wizard.

Lesson: Always use a cloud-only @yourtenant.onmicrosoft.com account for Entra Connect — never a personal Microsoft account.


Error 2 — M365 Developer Sandbox Not Available

What happened: Tried to sign up for the Microsoft 365 Developer Program to get a free E5 tenant with Conditional Access. Got message: "You don't currently qualify for a Microsoft 365 Developer Program sandbox subscription."

Root cause: Microsoft tightened eligibility in 2024–2025. Accounts without active development activity on GitHub or Visual Studio are often denied.

Fix: Used the existing Azure free account tenant instead. The Entra ID Free tier that comes with every Azure account was sufficient to run Entra Connect and sync users. For MFA, used Security Defaults (no license required) instead of Conditional Access (requires P1/P2).

Lesson: The M365 Developer sandbox denial is extremely common. The Azure free tenant works perfectly for hybrid identity labs. Security Defaults provides equivalent MFA baseline protection for free.

M365 Sandbox Denied


Error 3 — AADSTS700016: App registration failed in wrong tenant

What happened: During the final configuration step, Entra Connect tried to register itself as an application in the tenant but failed with: Application with identifier '0ca877e8...' was not found in the directory 'Microsoft Services'

Root cause: The wizard was still authenticated with the personal Outlook account from a previous failed attempt. The app registration tried to go to Microsoft Services (the personal account tenant) instead of my actual Entra tenant.

Fix:

  1. Found and deleted the orphaned app registration from Azure → App registrations → All applications
  2. Created the syncadmin@musahissahghoutlook.onmicrosoft.com account properly
  3. Signed that account into the Azure portal and completed password activation
  4. Reran the Entra Connect wizard using the syncadmin account — completed successfully

Lesson: When Entra Connect fails mid-installation, always clean up orphaned app registrations before rerunning. Check Azure → App Registrations → All Applications for any entries created on the failed run date.


Error 4 — Conditional Access Create Button Greyed Out

What happened: Navigated to Identity → Protection → Conditional Access → tried to create a policy — the Create button was unclickable.

Root cause: Conditional Access requires Microsoft Entra ID P1 or P2 license. Azure free tier only includes Entra ID Free.

Fix: Switched to Security Defaults, which provides equivalent baseline MFA enforcement without requiring a paid license. This is actually the Microsoft-recommended configuration for organizations without P1/P2 licensing.

Lesson: Understand the licensing model. Security Defaults = free, tenant-wide MFA baseline. Conditional Access = paid, granular policy control. For a home lab, Security Defaults achieves the same security goal.


PowerShell Scripts

Force Sync

# Force an immediate delta sync from on-prem AD to Microsoft Entra ID
# Run on the server where Entra Connect is installed (DC-01)
Import-Module "C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\ADSync.psd1"
Write-Host "Starting Entra Connect delta sync..." -ForegroundColor Cyan
Start-ADSyncSyncCycle -PolicyType Delta
Write-Host "Sync initiated. Check Synchronization Service Manager for results." -ForegroundColor Green

Update UPN Suffix in Bulk

# Bulk update UPN suffix for all users in a specific OU
$NewSuffix = '@musahissahghoutlook.onmicrosoft.com'
$OUPath = 'OU=Users,DC=company,DC=org'

$users = Get-ADUser -Filter * -SearchBase $OUPath
foreach ($user in $users) {
    $newUPN = $user.SamAccountName + $NewSuffix
    Set-ADUser $user -UserPrincipalName $newUPN
    Write-Host "Updated: $($user.SamAccountName) -> $newUPN" -ForegroundColor Green
}

Check Sync Status

# Check ADSync service status and last sync time
Get-Service ADSync
Get-ADSyncScheduler | Select-Object NextSyncCycleStartTimeInUTC, CurrentlyRunning, SyncCycleEnabled

Security Configuration

See docs/security-decisions.md for full documentation.

Summary: Security Defaults enabled — enforcing MFA for all 54 users including 51 synced from on-premises AD. This is the Microsoft-recommended baseline security configuration for organizations without Entra ID P1/P2 licensing.


Lessons Learned

  1. Entra Connect only downloads from the Entra Admin Center — not the Microsoft Download Center (changed in 2025)
  2. Personal Microsoft accounts cannot be used for Entra Connect — always create a dedicated cloud-only admin account in your tenant
  3. The M365 Developer Sandbox denial is common — the Azure free tenant is sufficient for hybrid identity labs
  4. Clean up failed installations before retrying — orphaned app registrations cause AADSTS700016 errors
  5. UPN suffix matching is critical — without it, users sync but cannot authenticate to cloud resources
  6. Security Defaults is not a consolation prize — it's a legitimate, widely-used enterprise security baseline

Project Stats

Metric Value
Build time ~6 hours including troubleshooting
Users synced 51 on-premises users
Total users in Entra 54 (including cloud-only admin accounts)
Sync runs completed 18 (visible in Synchronization Service Manager)
Errors encountered 4
Errors resolved 4
MFA enforced Yes — Security Defaults

Author

Musah Issah IT Support Specialist | New York, NY


This is Project 5 of my 10-project IT Support Portfolio. See my LinkedIn for the full series.

About

A comprehensive PowerShell automation project managing the full user lifecycle, from CSV data ingestion to Active Directory object creation and GPO-driven security enforcement.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors