Esercitazione: Ambiente Active Directory di base
Questa esercitazione illustra come creare un ambiente Active Directory 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 vengono fornite per le persone che potrebbero iniziare da nulla.
Sezioni dell'esercitazione
Prerequisiti
Per completare questa esercitazione sono necessari i requisiti seguenti
- Un computer in cui è installato Hyper-V. È consigliabile eseguire questa operazione in un computer Windows 10 o Windows Server 2016 .
- Una scheda di rete esterna per consentire alla macchina virtuale di comunicare con Internet.
- Una sottoscrizione di Azure
- Una copia di Windows Server 2016
- Microsoft .NET Framework 4.7.1
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.
Gli script usati creano un ambiente Active Directory generale prima di installare Microsoft Entra Connessione agente di provisioning cloud. 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:
Aprire PowerShell ISE come amministratore.
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.
- Nella console di gestione di Hyper-V fare doppio clic sulla macchina virtuale
- Fare clic sul pulsante Start.
- Verrà richiesto di premere un tasto qualsiasi per eseguire l'avvio da CD o DVD. Procedere.
- Nella schermata di avvio di Windows Server selezionare la lingua e fare clic su Avanti.
- Fare clic su Installa.
- Immettere il codice di licenza e fare clic su Avanti.
- Accettare le condizioni di licenza e fare clic su Avanti.
- Selezionare Custom: Install Windows Only (Advanced) (Personalizzato: installare solo Windows (Avanzato))
- Fare clic su Avanti.
- Dopo aver completato l'installazione, riavviare la macchina virtuale, accedere ed eseguire gli aggiornamenti di Windows per assicurarsi che la macchina virtuale sia 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:
Aprire PowerShell ISE come amministratore.
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:
Aprire PowerShell ISE come amministratore.
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:
Aprire PowerShell ISE come amministratore.
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 da cui si inizia.
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.
- Accedere all'interfaccia di amministrazione di Microsoft Entra e accedere con un account con l'abbonamento a Microsoft Entra.
- Fare clic su Panoramica.
- Fare clic su Gestisci tenant.
- Selezionare Crea
. - Specificare un nome per l'organizzazione e il nome di dominio iniziale. Selezionare Crea. Verrà così creata la directory.
- A questo punto, selezionare il collegamento qui per gestire la directory.
Creare un amministratore globale in Microsoft Entra ID
Ora che si dispone di un tenant di Microsoft Entra, si creerà un account amministratore globale. Per creare l'account di amministratore globale, eseguire le operazioni seguenti.
- In Gestisci selezionare Utenti.
- Selezionare Tutti gli utenti e selezionare +Nuovo utente.
- Specificare un nome e un nome utente per questo utente. Questo sarà il Amministrazione istrator globale per il tenant. Si vuole anche modificare il ruolo Directory in Amministratore globale. È anche possibile visualizzare la password temporanea. Al termine, selezionare Crea.
- Al termine dell'operazione, aprire un nuovo Web browser e accedere a myapps.microsoft.com usando il nuovo account di amministratore globale e la password temporanea.
- Modificare la password dell'amministratore globale scegliendone una facile da ricordare.
Facoltativo: server e foresta aggiuntivi
Di seguito è riportata una sezione facoltativa che illustra la procedura per la creazione di un server e/o di una foresta aggiuntiva, Questo può essere usato in alcune delle esercitazioni più avanzate, ad esempio Pilot for Microsoft Entra Connessione to cloud sync.
Se è necessario solo un server aggiuntivo, è possibile fermarsi dopo il passaggio Creare la macchina virtuale e aggiungere il server al dominio esistente creato in precedenza.
Creare una macchina virtuale
Aprire PowerShell ISE come amministratore.
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.
- Nella console di gestione di Hyper-V fare doppio clic sulla macchina virtuale
- Fare clic sul pulsante Start.
- Verrà richiesto di premere un tasto qualsiasi per eseguire l'avvio da CD o DVD. Procedere.
- Nella schermata di avvio di Windows Server selezionare la lingua e fare clic su Avanti.
- Fare clic su Installa.
- Immettere il codice di licenza e fare clic su Avanti.
- Accettare le condizioni di licenza e fare clic su Avanti.
- Selezionare Custom: Install Windows Only (Advanced) (Personalizzato: installare solo Windows (Avanzato))
- Fare clic su Avanti.
- Dopo aver completato l'installazione, riavviare la macchina virtuale, accedere ed eseguire gli aggiornamenti di Windows per assicurarsi che la macchina virtuale sia 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:
Aprire PowerShell ISE come amministratore.
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:
Aprire PowerShell ISE come amministratore.
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:
Aprire PowerShell ISE come amministratore.
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 funzionalità aggiuntive fornite dalla sincronizzazione cloud.