Compartilhar via

在 AD DS 中更新存储帐户标识的密码

适用于: ✔️ SMB Azure 文件共享

当您将存储帐户加入到 Active Directory 域服务 (AD DS) 时,需要创建一个带有密码的 AD 主体(计算机帐户或服务帐户)。 Active Directory 主体的密码是存储帐户的 Kerberos 密钥之一。 根据 AD 主体的组织单位的密码策略,必须定期轮换密码以避免身份验证问题。 如果在密码过期之前未更改密码,则会丢失对 Azure 文件共享的 Kerberos 身份验证。 某些 AD 环境还使用自动清理脚本删除具有过期密码的 AD 主体。

还可以将表示存储帐户的 AD 主体放入不需要密码轮换的组织单位,而不是定期轮换密码。

存在两个选项用于触发密码轮换。 可以使用 AzFilesHybrid 模块或 Active Directory PowerShell。 请使用一种方法,而不是同时使用两种方法。

选项 1:使用 AzFilesHybrid 模块

若要重新生成并轮换表示存储帐户的 AD 主体的密码,请使用 Update-AzStorageAccountADObjectPasswordAzFilesHybrid 模块中的 cmdlet。 若要运行 Update-AzStorageAccountADObjectPassword,必须:

  • 从加入域的客户端运行 cmdlet。
  • 拥有存储帐户的所有者权限。
  • 具有 AD DS 权限以更改表示存储帐户的 AD 主体的密码。
# Update the password of the AD DS account registered for the storage account
# You can use either kerb1 or kerb2
Update-AzStorageAccountADObjectPassword `
        -RotateToKerbKey kerb2 `
        -ResourceGroupName "<your-resource-group-name-here>" `
        -StorageAccountName "<your-storage-account-name-here>"

轮换到 kerb2 后,请等待几个小时,然后再次使用 Update-AzStorageAccountADObjectPassword cmdlet 重新生成并重新轮换回 kerb1,以便重新生成两个 Kerberos 密钥。

选项 2:使用 Active Directory PowerShell

如果不想下载 AzFilesHybrid 模块,可以使用 Active Directory PowerShell

重要

必须在 PowerShell 5.1 的提升权限下运行本节中的 Windows Server Active Directory PowerShell cmdlets。

将以下脚本中的 <domain-object-identity> 替换为你的环境的相应值:

$KeyName = "kerb1" # Could be either the first or second Kerberos key, this script assumes we're refreshing the first
$KerbKeys = New-AzStorageAccountKey -ResourceGroupName $ResourceGroupName -Name $StorageAccountName -KeyName $KeyName
$KerbKey = $KerbKeys.keys | Where-Object {$_.KeyName -eq $KeyName} | Select-Object -ExpandProperty Value
$NewPassword = ConvertTo-SecureString -String $KerbKey -AsPlainText -Force

Set-ADAccountPassword -Identity <domain-object-identity> -Reset -NewPassword $NewPassword

测试 AD DS 帐户密码是否与 Kerberos 密钥匹配

更新 AD DS 帐户密码后,使用以下 PowerShell 命令对其进行测试。

 Test-AzStorageAccountADObjectPasswordIsKerbKey -ResourceGroupName "<your-resource-group-name>" -Name "<your-storage-account-name>" -Verbose