Condividi tramite


Esercitazione: Ambiente Active Directory di base

Questa esercitazione illustra come creare un ambiente Active Directory di base.

Diagramma che mostra un ambiente Microsoft Entra di base.

È possibile usare l'ambiente creato nell'esercitazione per testare vari aspetti degli scenari di identità ibrida e tale ambiente sarà un prerequisito per alcune delle esercitazioni. Se si dispone già di un ambiente Active Directory esistente, è possibile usarlo come sostituto. Queste informazioni sono destinate a singoli utenti che iniziano da zero.

Prerequisiti

Per completare questa esercitazione sono necessari i requisiti seguenti

Nota

Questa esercitazione usa script di PowerShell in modo che sia possibile creare l'ambiente dell'esercitazione molto velocemente. Ogni script usa variabili dichiarate all'inizio degli script. È possibile ed è consigliabile modificare le variabili in base al proprio ambiente.

L'uso degli script consente di creare un ambiente Active Directory generale prima dell'installazione dell'agente di provisioning cloud di Microsoft Entra Connect. Sono rilevanti per tutte le esercitazioni.

Le copie degli script di PowerShell usati in questa esercitazione sono disponibili in GitHub qui.

Creare una macchina virtuale

Per configurare un ambiente ibrido di gestione delle identità operativo, è prima necessario creare una macchina virtuale che servirà come server Active Directory locale. Effettua le operazioni seguenti:

  1. Aprire PowerShell ISE come amministratore.
  2. Eseguire lo script seguente.
#Declare variables
$VMName = 'DC1'
$Switch = 'External'
$InstallMedia = 'D:\ISO\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso'
$Path = 'D:\VM'
$VHDPath = 'D:\VM\DC1\DC1.vhdx'
$VHDSize = '64424509440'

#Create New Virtual Machine
New-VM -Name $VMName -MemoryStartupBytes 16GB -BootDevice VHD -Path $Path -NewVHDPath $VHDPath -NewVHDSizeBytes $VHDSize -Generation 2 -Switch $Switch 

#Set the memory to be non-dynamic
Set-VMMemory $VMName -DynamicMemoryEnabled $false

#Add DVD Drive to Virtual Machine
Add-VMDvdDrive -VMName $VMName -ControllerNumber 0 -ControllerLocation 1 -Path $InstallMedia

#Mount Installation Media
$DVDDrive = Get-VMDvdDrive -VMName $VMName

#Configure Virtual Machine to Boot from DVD
Set-VMFirmware -VMName $VMName -FirstBootDevice $DVDDrive 

Completare la distribuzione del sistema operativo

Per concludere la creazione della macchina virtuale, è necessario completare l'installazione del sistema operativo.

  1. Nella console di gestione di Hyper-V fare doppio clic sulla macchina virtuale
  2. Fare clic sul pulsante Start.
  3. Verrà richiesto di premere un tasto qualsiasi per eseguire l'avvio da CD o DVD. Procedere.
  4. Nella schermata di avvio di Windows Server selezionare la lingua e fare clic su Avanti.
  5. Fare clic su Installa.
  6. Immettere il codice di licenza e fare clic su Avanti.
  7. Accettare le condizioni di licenza e fare clic su Avanti.
  8. Selezionare Custom: Install Windows Only (Advanced) (Personalizzato: installare solo Windows (Avanzato))
  9. Fare clic su Avanti.
  10. Al termine dell'installazione, riavviare la macchina virtuale, accedere ed eseguire gli aggiornamenti di Windows per assicurarsi che la macchina virtuale sia più aggiornata. Installare gli ultimi aggiornamenti.

Installare i prerequisiti di Active Directory

Ora che la macchina virtuale è disponibile, è necessario eseguire alcune operazioni prima di installare Active Directory. È necessario rinominare la macchina virtuale, impostare un indirizzo IP statico e le informazioni DNS e installare gli strumenti di amministrazione remota del server. Effettua le operazioni seguenti:

  1. Aprire PowerShell ISE come amministratore.
  2. Eseguire lo script seguente.
#Declare variables
$ipaddress = "10.0.1.117" 
$ipprefix = "24" 
$ipgw = "10.0.1.1" 
$ipdns = "10.0.1.117"
$ipdns2 = "8.8.8.8" 
$ipif = (Get-NetAdapter).ifIndex 
$featureLogPath = "c:\poshlog\featurelog.txt" 
$newname = "DC1"
$addsTools = "RSAT-AD-Tools" 

#Set static IP address
New-NetIPAddress -IPAddress $ipaddress -PrefixLength $ipprefix -InterfaceIndex $ipif -DefaultGateway $ipgw 

# Set the DNS servers
Set-DnsClientServerAddress -InterfaceIndex $ipif -ServerAddresses ($ipdns, $ipdns2)

#Rename the computer 
Rename-Computer -NewName $newname -force 

#Install features 
New-Item $featureLogPath -ItemType file -Force 
Add-WindowsFeature $addsTools 
Get-WindowsFeature | Where installed >>$featureLogPath 

#Restart the computer 
Restart-Computer

Creare un ambiente di Active Directory per Windows Server

Dopo che la macchina virtuale è stata creata e rinominata e ha un indirizzo IP statico, è possibile installare e configurare Active Directory Domain Services. Effettua le operazioni seguenti:

  1. Aprire PowerShell ISE come amministratore.
  2. Eseguire lo script seguente.
#Declare variables
$DatabasePath = "c:\windows\NTDS"
$DomainMode = "WinThreshold"
$DomainName = "contoso.com"
$DomaninNetBIOSName = "CONTOSO"
$ForestMode = "WinThreshold"
$LogPath = "c:\windows\NTDS"
$SysVolPath = "c:\windows\SYSVOL"
$featureLogPath = "c:\poshlog\featurelog.txt" 
$Password = "Pass1w0rd"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force

#Install AD DS, DNS and GPMC 
start-job -Name addFeature -ScriptBlock { 
Add-WindowsFeature -Name "ad-domain-services" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "dns" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "gpmc" -IncludeAllSubFeature -IncludeManagementTools } 
Wait-Job -Name addFeature 
Get-WindowsFeature | Where installed >>$featureLogPath

#Create New AD Forest
Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath $DatabasePath -DomainMode $DomainMode -DomainName $DomainName -SafeModeAdministratorPassword $SecureString -DomainNetbiosName $DomainNetBIOSName -ForestMode $ForestMode -InstallDns:$true -LogPath $LogPath -NoRebootOnCompletion:$false -SysvolPath $SysVolPath -Force:$true

Creare un utente di Active Directory per Windows Server

Ora che l'ambiente Active Directory è pronto, è necessario un account di test. Questo account verrà creato nell'ambiente AD locale e quindi sincronizzato con Microsoft Entra ID. Effettua le operazioni seguenti:

  1. Aprire PowerShell ISE come amministratore.
  2. Eseguire lo script seguente.
# Filename:  4_CreateUser.ps1
# Description: Creates a user in Active Directory. This is part of
#       the Azure AD Connect password hash sync tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. This 
# script is made available to you without any express, implied or 
# statutory warranty, not even the implied warranty of 
# merchantability or fitness for a particular purpose, or the 
# warranty of title or non-infringement. The entire risk of the 
# use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$Givenname = "Allie"
$Surname = "McCray"
$Displayname = "Allie McCray"
$Name = "amccray"
$Password = "Pass1w0rd"
$Identity = "CN=ammccray,CN=Users,DC=contoso,DC=com"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force


#Create the user
New-ADUser -Name $Name -GivenName $Givenname -Surname $Surname -DisplayName $Displayname -AccountPassword $SecureString

#Set the password to never expire
Set-ADUser -Identity $Identity -PasswordNeverExpires $true -ChangePasswordAtLogon $false -Enabled $true

Creare un tenant di Microsoft Entra

Suggerimento

I passaggi descritti in questo articolo possono variare leggermente in base al portale di partenza.

A questo punto è necessario creare un tenant di Microsoft Entra in modo da poter sincronizzare gli utenti con il cloud. Per creare un nuovo tenant di Microsoft Entra, eseguire le operazioni seguenti.

  1. Accedere all'interfaccia di amministrazione di Microsoft Entra e accedere con un account con la sottoscrizione di Microsoft Entra.
  2. Fare clic su Panoramica.
  3. Fare clic su Gestisci i tenant.
  4. Selezionare Crea
    .
  5. Specificare un nome per l'organizzazione e il nome di dominio iniziale. Selezionare Crea. Verrà così creata la directory.
  6. A questo punto, selezionare il collegamento qui per gestire la directory.

Creare un amministratore delle identità ibride in Microsoft Entra ID

Ora che si dispone di un tenant di Microsoft Entra, si creerà un account di amministratore delle identità ibride. Per creare l'account di amministratore delle identità ibride, seguire questa procedura.

  1. In Gestisci selezionare Utenti.
    Screenshot che mostra il menu
  2. Selezionare Tutti gli utenti e selezionare +Nuovo utente.
  3. Specificare un nome e un nome utente per questo utente. Questo sarà l'amministratore dell'identità ibrida per il tenant. Si vuole anche modificare il ruolo Directory in Amministratore identità ibrida. È anche possibile visualizzare la password temporanea. Al termine, selezionare Crea.
    Creazione
  4. Al termine, aprire un nuovo Web browser e accedere per myapps.microsoft.com usando il nuovo account amministratore delle identità ibride e la password temporanea.
  5. Modificare la password per l'amministratore dell'identità ibrida in un elemento che verrà ricordato.

Facoltativo: un altro server e un'altra foresta

Di seguito è riportata una sezione facoltativa che illustra la procedura per creare un altro server e un'altra foresta. Potrebbero essere necessari in alcune delle esercitazioni più avanzate, ad esempio Creare un progetto pilota per la sincronizzazione cloud di Microsoft Entra Connect.

Se è necessario un altro server, è possibile arrestarsi dopo il passaggio - Creare la macchina virtuale e aggiungere il server al dominio esistente creato in precedenza.

Creare una macchina virtuale

  1. Aprire PowerShell ISE come amministratore.
  2. Eseguire lo script seguente.
# Filename:  1_CreateVM_CP.ps1
# Description: Creates a VM to be used in the tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. #This script is made available to you without any express, implied or statutory warranty, not even the implied warranty of merchantability or fitness for a particular purpose, or the warranty of title or non-infringement. The entire risk of the use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$VMName = 'CP1'
$Switch = 'External'
$InstallMedia = 'D:\ISO\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso'
$Path = 'D:\VM'
$VHDPath = 'D:\VM\CP1\CP1.vhdx'
$VHDSize = '64424509440'

#Create New Virtual Machine
New-VM -Name $VMName -MemoryStartupBytes 16GB -BootDevice VHD -Path $Path -NewVHDPath $VHDPath -NewVHDSizeBytes $VHDSize -Generation 2 -Switch $Switch 

#Set the memory to be non-dynamic
Set-VMMemory $VMName -DynamicMemoryEnabled $false

#Add DVD Drive to Virtual Machine
Add-VMDvdDrive -VMName $VMName -ControllerNumber 0 -ControllerLocation 1 -Path $InstallMedia

#Mount Installation Media
$DVDDrive = Get-VMDvdDrive -VMName $VMName

#Configure Virtual Machine to Boot from DVD
Set-VMFirmware -VMName $VMName -FirstBootDevice $DVDDrive

Completare la distribuzione del sistema operativo

Per concludere la creazione della macchina virtuale, è necessario completare l'installazione del sistema operativo.

  1. Nella console di gestione di Hyper-V fare doppio clic sulla macchina virtuale
  2. Fare clic sul pulsante Start.
  3. Verrà richiesto di premere un tasto qualsiasi per eseguire l'avvio da CD o DVD. Procedere.
  4. Nella schermata di avvio di Windows Server selezionare la lingua e fare clic su Avanti.
  5. Fare clic su Installa.
  6. Immettere il codice di licenza e fare clic su Avanti.
  7. Accettare le condizioni di licenza e fare clic su Avanti.
  8. Selezionare Custom: Install Windows Only (Advanced) (Personalizzato: installare solo Windows (Avanzato))
  9. Fare clic su Avanti.
  10. Al termine dell'installazione, riavviare la macchina virtuale, accedere ed eseguire gli aggiornamenti di Windows per assicurarsi che la macchina virtuale sia più aggiornata. Installare gli ultimi aggiornamenti.

Installare i prerequisiti di Active Directory

Ora che la macchina virtuale è disponibile, è necessario eseguire alcune operazioni prima di installare Active Directory. È necessario rinominare la macchina virtuale, impostare un indirizzo IP statico e le informazioni DNS e installare gli strumenti di amministrazione remota del server. Effettua le operazioni seguenti:

  1. Aprire PowerShell ISE come amministratore.
  2. Eseguire lo script seguente.
# Filename:  2_ADPrep_CP.ps1
# Description: Prepares your environment for Active Directory. This is part of
#       the Azure AD Connect password hash sync tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. This 
# script is made available to you without any express, implied or 
# statutory warranty, not even the implied warranty of 
# merchantability or fitness for a particular purpose, or the 
# warranty of title or non-infringement. The entire risk of the 
# use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$ipaddress = "10.0.1.118" 
$ipprefix = "24" 
$ipgw = "10.0.1.1" 
$ipdns = "10.0.1.118"
$ipdns2 = "8.8.8.8" 
$ipif = (Get-NetAdapter).ifIndex 
$featureLogPath = "c:\poshlog\featurelog.txt" 
$newname = "CP1"
$addsTools = "RSAT-AD-Tools" 

#Set static IP address
New-NetIPAddress -IPAddress $ipaddress -PrefixLength $ipprefix -InterfaceIndex $ipif -DefaultGateway $ipgw 

#Set the DNS servers
Set-DnsClientServerAddress -InterfaceIndex $ipif -ServerAddresses ($ipdns, $ipdns2)

#Rename the computer 
Rename-Computer -NewName $newname -force 

#Install features 
New-Item $featureLogPath -ItemType file -Force 
Add-WindowsFeature $addsTools 
Get-WindowsFeature | Where installed >>$featureLogPath 

#Restart the computer 
Restart-Computer

Creare un ambiente di Active Directory per Windows Server

Dopo che la macchina virtuale è stata creata e rinominata e ha un indirizzo IP statico, è possibile installare e configurare Active Directory Domain Services. Effettua le operazioni seguenti:

  1. Aprire PowerShell ISE come amministratore.
  2. Eseguire lo script seguente.
# Filename:  3_InstallAD_CP.ps1
# Description: Creates an on-premises AD environment. This is part of
#       the Azure AD Connect password hash sync tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. This 
# script is made available to you without any express, implied or 
# statutory warranty, not even the implied warranty of 
# merchantability or fitness for a particular purpose, or the 
# warranty of title or non-infringement. The entire risk of the 
# use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$DatabasePath = "c:\windows\NTDS"
$DomainMode = "WinThreshold"
$DomainName = "fabrikam.com"
$DomaninNetBIOSName = "FABRIKAM"
$ForestMode = "WinThreshold"
$LogPath = "c:\windows\NTDS"
$SysVolPath = "c:\windows\SYSVOL"
$featureLogPath = "c:\poshlog\featurelog.txt" 
$Password = "Pass1w0rd"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force

#Install AD DS, DNS and GPMC 
start-job -Name addFeature -ScriptBlock { 
Add-WindowsFeature -Name "ad-domain-services" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "dns" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "gpmc" -IncludeAllSubFeature -IncludeManagementTools } 
Wait-Job -Name addFeature 
Get-WindowsFeature | Where installed >>$featureLogPath

#Create New AD Forest
Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath $DatabasePath -DomainMode $DomainMode -DomainName $DomainName -SafeModeAdministratorPassword $SecureString -DomainNetbiosName $DomainNetBIOSName -ForestMode $ForestMode -InstallDns:$true -LogPath $LogPath -NoRebootOnCompletion:$false -SysvolPath $SysVolPath -Force:$true

Creare un utente di Active Directory per Windows Server

Ora che l'ambiente Active Directory è pronto, è necessario un account di test. Questo account verrà creato nell'ambiente AD locale e quindi sincronizzato con Microsoft Entra ID. Effettua le operazioni seguenti:

  1. Aprire PowerShell ISE come amministratore.
  2. Eseguire lo script seguente.
# Filename:  4_CreateUser_CP.ps1
# Description: Creates a user in Active Directory. This is part of
#       the Azure AD Connect password hash sync tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. This 
# script is made available to you without any express, implied or 
# statutory warranty, not even the implied warranty of 
# merchantability or fitness for a particular purpose, or the 
# warranty of title or non-infringement. The entire risk of the 
# use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$Givenname = "Anna"
$Surname = "Ringdal"
$Displayname = "Anna Ringdal"
$Name = "aringdal"
$Password = "Pass1w0rd"
$Identity = "CN=aringdal,CN=Users,DC=fabrikam,DC=com"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force


#Create the user
New-ADUser -Name $Name -GivenName $Givenname -Surname $Surname -DisplayName $Displayname -AccountPassword $SecureString

#Set the password to never expire
Set-ADUser -Identity $Identity -PasswordNeverExpires $true -ChangePasswordAtLogon $false -Enabled $true

Conclusione

A questo punto è disponibile un ambiente che può essere usato per le esercitazioni esistenti e per testare altre funzionalità offerte dalla sincronizzazione cloud.

Passaggi successivi