Skip to content

Commit 872889d

Browse files
authored
Merge pull request #218750 from khdownie/kendownie111722
adding second option for pw rotation
2 parents 63b2cab + ba1d862 commit 872889d

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

articles/storage/files/storage-files-identity-ad-ds-update-password.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,31 @@ author: khdownie
55
ms.service: storage
66
ms.subservice: files
77
ms.topic: how-to
8-
ms.date: 11/16/2022
8+
ms.date: 11/17/2022
99
ms.author: kendownie
1010
---
1111

1212
# Update the password of your storage account identity in AD DS
1313

1414
If you registered the Active Directory Domain Services (AD DS) identity/account that represents your storage account in an organizational unit or domain that enforces password expiration time, you must change the password before the maximum password age. Your organization may run automated cleanup scripts that delete accounts once their password expires. Because of this, if you don't change your password before it expires, your account could be deleted, which will cause you to lose access to your Azure file shares.
1515

16+
To prevent unintended password rotation, during the onboarding of the Azure storage account in the domain, make sure to place the Azure storage account into a separate organizational unit in AD DS. Disable Group Policy inheritance on this organizational unit to prevent default domain policies or specific password policies from being applied.
17+
1618
> [!NOTE]
1719
> A storage account identity in AD DS can be either a service account or a computer account. Service account passwords can expire in AD; however, because computer account password changes are driven by the client machine and not AD, they don't expire in AD.
1820
19-
To trigger password rotation, you can run the `Update-AzStorageAccountADObjectPassword` cmdlet from the [AzFilesHybrid module](https://github.com/Azure-Samples/azure-files-samples/releases). This command must be run in an on-premises AD DS-joined environment by a [hybrid identity](../../active-directory/hybrid/whatis-hybrid-identity.md) with owner permission to the storage account and AD DS permissions to change the password of the identity representing the storage account. The command performs actions similar to storage account key rotation. Specifically, it gets the second Kerberos key of the storage account and uses it to update the password of the registered account in AD DS. Then it regenerates the target Kerberos key of the storage account and updates the password of the registered account in AD DS.
21+
There are two options for triggering password rotation. You can use the `AzFilesHybrid` module or Active Directory PowerShell. Use one method, not both.
22+
23+
## Applies to
24+
| File share type | SMB | NFS |
25+
|-|:-:|:-:|
26+
| Standard file shares (GPv2), LRS/ZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
27+
| Standard file shares (GPv2), GRS/GZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
28+
| Premium file shares (FileStorage), LRS/ZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
29+
30+
## Use AzFilesHybrid module
2031

21-
To prevent password rotation, during the onboarding of the Azure storage account in the domain, make sure to place the Azure storage account into a separate organizational unit in AD DS. Disable Group Policy inheritance on this organizational unit to prevent default domain policies or specific password policies to be applied.
32+
You can run the `Update-AzStorageAccountADObjectPassword` cmdlet from the [AzFilesHybrid module](https://github.com/Azure-Samples/azure-files-samples/releases). This command must be run in an on-premises AD DS-joined environment by a [hybrid identity](../../active-directory/hybrid/whatis-hybrid-identity.md) with owner permission to the storage account and AD DS permissions to change the password of the identity representing the storage account. The command performs actions similar to storage account key rotation. Specifically, it gets the second Kerberos key of the storage account and uses it to update the password of the registered account in AD DS. Then it regenerates the target Kerberos key of the storage account and updates the password of the registered account in AD DS.
2233

2334
```PowerShell
2435
# Update the password of the AD DS account registered for the storage account
@@ -31,9 +42,21 @@ Update-AzStorageAccountADObjectPassword `
3142

3243
This action will change the password for the AD object from kerb1 to kerb2. This is intended to be a two-stage process: rotate from kerb1 to kerb2 (kerb2 will be regenerated on the storage account before being set), wait several hours, and then rotate back to kerb1 (this cmdlet will likewise regenerate kerb1).
3344

34-
## Applies to
35-
| File share type | SMB | NFS |
36-
|-|:-:|:-:|
37-
| Standard file shares (GPv2), LRS/ZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
38-
| Standard file shares (GPv2), GRS/GZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
39-
| Premium file shares (FileStorage), LRS/ZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
45+
## Use Active Directory PowerShell
46+
47+
If you don't want to download the `AzFilesHybrid` module, you can use [Active Directory PowerShell](/powershell/module/activedirectory).
48+
49+
> [!IMPORTANT]
50+
> The Windows Server Active Directory PowerShell cmdlets in this section must be run in Windows PowerShell 5.1 with elevated privileges. PowerShell 7.x and Azure Cloud Shell won't work in this scenario.
51+
52+
Replace `<domain-object-identity>` in the following script with your value, then run the script to update your domain object password:
53+
54+
```powershell
55+
$KeyName = "kerb1" # Could be either the first or second kerberos key, this script assumes we're refreshing the first
56+
$KerbKeys = New-AzStorageAccountKey -ResourceGroupName $ResourceGroupName -Name $StorageAccountName -KeyName $KeyName
57+
$KerbKey = $KerbKeys.keys | Where-Object {$_.KeyName -eq $KeyName} | Select-Object -ExpandProperty Value
58+
$NewPassword = ConvertTo-SecureString -String $KerbKey -AsPlainText -Force
59+
60+
Set-ADAccountPassword -Identity <domain-object-identity> -Reset -NewPassword $NewPassword
61+
```
62+

0 commit comments

Comments
 (0)