修改密码时权限不足
Insufficient privileges while changing password
我正在尝试使用 docker 容器内的 Azure Powershell(AZ powershell 模块)来 create/modify office 365 相关配置,包括用户配置文件。
我正在尝试使用服务主体更改用户密码。使用 Update-AzADUser
时出现以下错误。但是,我可以创建用户并修改显示名称。我只遇到更改密码或删除用户的问题。
PS /> Update-AzADUser -ObjectId xyz358c2... -Password $password
Update-AzADUser : Insufficient privileges to complete the operation.
At line:1 char:1
+ Update-AzADUser -ObjectId xyz358c2... -Passw ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Update-AzADUser], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ActiveDirectory.UpdateAzureADUserCommand
关于服务主体,我已经在 Microsoft Graph API 和 Windows Azure 上提供了所有可用的应用程序权限和委派权限活动目录.
我找不到任何可在 https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/directory-assign-admin-roles 中分配给服务主体的 AD 角色。请在以下链接上截图。
Permissions
Roles
正如评论中所讨论的,您应该尝试为您正在使用的服务主体分配适当的目录角色,以便它可以获得足够的权限。
这是执行该操作的快速脚本。根据您的要求更改服务主体名称和角色名称。
# Get to the service principal
$svcPrincipalId = (Get-AzureADServicePrincipal -SearchString "your service principal name").ObjectId
# I am using Helpdesk administrator here, but feel free to change this name as per your requirement.
# You can get a complete list of role templates using Get-AzureADDirectoryRoleTemplate.
# Helpdesk admninstrator role can reset passwords for non-administrators.
$roleName = 'Helpdesk administrator'
# Fetch User Account Administrator role instance
$role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq $roleName}
# If role instance does not exist, instantiate it based on the role template
if ($role -eq $null) {
# Instantiate an instance of the role template
$roleTemplate = Get-AzureADDirectoryRoleTemplate | Where-Object {$_.displayName -eq $roleName}
Enable-AzureADDirectoryRole -RoleTemplateId $roleTemplate.ObjectId
# Fetch User Account Administrator role instance again
$role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq $roleName}
}
# Add user to role
Add-AzureADDirectoryRoleMember -ObjectId $role.ObjectId -RefObjectId $svcPrincipalId
我正在尝试使用 docker 容器内的 Azure Powershell(AZ powershell 模块)来 create/modify office 365 相关配置,包括用户配置文件。
我正在尝试使用服务主体更改用户密码。使用 Update-AzADUser
时出现以下错误。但是,我可以创建用户并修改显示名称。我只遇到更改密码或删除用户的问题。
PS />
Update-AzADUser -ObjectId xyz358c2... -Password $password
Update-AzADUser : Insufficient privileges to complete the operation.
At line:1 char:1
+Update-AzADUser -ObjectId xyz358c2... -Passw ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Update-AzADUser], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ActiveDirectory.UpdateAzureADUserCommand
关于服务主体,我已经在 Microsoft Graph API 和 Windows Azure 上提供了所有可用的应用程序权限和委派权限活动目录.
我找不到任何可在 https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/directory-assign-admin-roles 中分配给服务主体的 AD 角色。请在以下链接上截图。
Permissions
Roles
正如评论中所讨论的,您应该尝试为您正在使用的服务主体分配适当的目录角色,以便它可以获得足够的权限。
这是执行该操作的快速脚本。根据您的要求更改服务主体名称和角色名称。
# Get to the service principal
$svcPrincipalId = (Get-AzureADServicePrincipal -SearchString "your service principal name").ObjectId
# I am using Helpdesk administrator here, but feel free to change this name as per your requirement.
# You can get a complete list of role templates using Get-AzureADDirectoryRoleTemplate.
# Helpdesk admninstrator role can reset passwords for non-administrators.
$roleName = 'Helpdesk administrator'
# Fetch User Account Administrator role instance
$role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq $roleName}
# If role instance does not exist, instantiate it based on the role template
if ($role -eq $null) {
# Instantiate an instance of the role template
$roleTemplate = Get-AzureADDirectoryRoleTemplate | Where-Object {$_.displayName -eq $roleName}
Enable-AzureADDirectoryRole -RoleTemplateId $roleTemplate.ObjectId
# Fetch User Account Administrator role instance again
$role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq $roleName}
}
# Add user to role
Add-AzureADDirectoryRoleMember -ObjectId $role.ObjectId -RefObjectId $svcPrincipalId