问题
In the Azure Portal, when navigating to a SQL Server, I can see/edit it's users and AD Admin.
Is there a way to get/list all users & admin(s) of SQL Server via API?
Looking thru the Azure API Reference I couldn't find any such API.
Edit: By SQL Users I mean users set via: By AD Admin I mean the user set via:
回答1:
Users: via powershell or via REST - see "List role assignments at a specific scope"
AD Administrator: via powershell- see "Provision an Azure AD administrator for Azure SQL Server by using PowerShell". There seems to be a reference that would indicate an intent to expose this via the REST API, but it seems to be missing from the documentation. Let me see what we can do about that.
Edit: The powershell command that would list all Role assignments for a specific SQL server would be:
Get-AzureRmRoleAssignment -ResourceGroupName <your resource group name> -ResourceType Microsoft.Sql/servers -ResourceName <your server name> -IncludeClassicAdministrators
A similar approach is possible with the REST commands.
Important to note: This only enumerates the Azure permission set, and no RBAC on the SQL Server level is enumerated here.
来源:https://stackoverflow.com/questions/39192490/azure-rest-api-how-to-get-sql-server-users-admin