Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to fetch User Permissions from AzureSQL #5076

Closed
4 tasks done
Ayanmullick opened this issue Feb 11, 2019 · 9 comments
Closed
4 tasks done

Unable to fetch User Permissions from AzureSQL #5076

Ayanmullick opened this issue Feb 11, 2019 · 9 comments
Assignees
Labels
azure sql Command has issue with Azure SQL due to unsupported SMO or T-SQL code.

Comments

@Ayanmullick
Copy link

Ayanmullick commented Feb 11, 2019

Before submitting a bug report:

  • Ensure you are able to reproduce it on the latest released version (we release often)
  • Verified this bug is not already reported in an issue
  • Verified errors are not related to permissions
  • Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)

Steps to Reproduce

Get-DbaUserPermission -SqlInstance 'tcp:<AzSQL ServerName>.database.windows.net,1433' -Database <AzSQLdbName> -SqlCredential <SQLadmin> -Verbose|ft

Expected Behavior

ComputerName InstanceName SqlInstance Object Type Member RoleSecurableClass
ServerName MSSQLSERVER ServerName SERVER SERVER LOGINS CORP<Group> None
ServerName MSSQLSERVER ServerName SERVER SERVER LOGINS CORP<Group> None
ServerName MSSQLSERVER ServerName SERVER SERVER LOGINS CORP<Group> None

Actual Behavior

VERBOSE: [19:13:53][Get-DbaUserPermission] Processing [<>] on TCP:<>.database.windows.net,1433
VERBOSE: [19:13:53][Get-DbaUserPermission] Creating objects
VERBOSE: [19:13:53][Get-DbaUserPermission] Building data table for server objects
VERBOSE: [19:13:53][Get-DbaUserPermission] Building data table for [<>] objects
VERBOSE: [19:13:53][Get-DbaUserPermission] Deleting objects

Environmental data

  • PowerShell:
Name Value
PSVersion 5.1.14393.2636
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.2636
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
  • SQL Server: Microsoft SQL Azure (RTM) - 12.0.2000.8 Dec 19 2018 08:43:17 Copyright (C) 2018 Microsoft Corporation
@EmanueleMeazzo
Copy link

Maybe it's the same issue that I have with another cmdlet #5122 , because the way which DBATools connects to the instance (connecting to the default DB and then switching to the -Database) doesn't work with Azure SQL DB

@wsmelton
Copy link
Member

Be aware that we do not actively support Azure SQL in every command. Commands that we have using strictly SMO are not (on average) going to all work against Azure SQL because SMO is not supported for it. Azure SQL is commonly managed by Az module, Azure CLI and the REST API.

This command is going to be an example @Ayanmullick where it will never work on Azure SQL because we are querying DMVs that are not allowed in Azure SQL. To gather permissions for a given user we are querying the syslogin view, that view is not accessible in Azure SQL. We also explicitly call out use for creating tables in tempdb, which I do not believe works in Azure SQL either but have not tried.

@wsmelton wsmelton added the azure sql Command has issue with Azure SQL due to unsupported SMO or T-SQL code. label Feb 28, 2019
@Ayanmullick
Copy link
Author

@wsmelton I verified with our MS TAM. SMO is MS-supported on AzSQLdb.

@wsmelton
Copy link
Member

wsmelton commented Feb 28, 2019

On this command it is irrelevant as this command as-is will not support use against Azure SQL.

@Ayanmullick
Copy link
Author

The below will connect you to an AzSQLdb thru SMO

Import-Module sql-smo
$sqlcc = new-object ('System.Data.SqlClient.SqlConnection') "Server=tcp:<>.database.windows.net,1433;Initial Catalog=<>;Persist Security Info=False;User ID=<>;Password=<>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication='Active Directory Password';"
$sc = new-object ('Microsoft.SqlServer.Management.Common.ServerConnection') $sqlcc
$srv = new-object ('Microsoft.SqlServer.Management.Smo.Server') $sc

$srv.Databases|ft #validate connection

@wsmelton
Copy link
Member

wsmelton commented Mar 6, 2019

We don't provide plain text passwords on the module... Not allowed and PS gallery will flag it if we do.

To support that it requires use of pscredential object, not providing a custom connection string (unless it can be done without passing a plain text passwords). The main internal connect command will have to be modified if SMO indeed supports it.

@potatoqualitee
Copy link
Member

we were planning on support for azure integrated auth, it seems like fun, i'll see what i can do tonight.

#4670

@potatoqualitee potatoqualitee self-assigned this Mar 6, 2019
@wsmelton
Copy link
Member

wsmelton commented May 5, 2019

@potatoqualitee be aware that fixing the auth issue will not fix this command for Azure SQL. As stated above this command, Get-DbaUserPermission, uses code that is not supported for Azure SQL. The STIG queries are not written to be run against Azure SQL databases.

@potatoqualitee
Copy link
Member

Thank you @wsmelton. It is true, the underlying T-SQL code, as provided by DISA, does not support this type of permission export. We can now authenticate to Azure SQL Db using various auths, and SMO does work (albeit in a limited capacity, by design) but DISA's T-SQL does not support Azure. If that changes, we'll add it to this command.

potatoqualitee added a commit that referenced this issue May 10, 2019
* azure unsupported for now - addresses #5076

* add a throw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure sql Command has issue with Azure SQL due to unsupported SMO or T-SQL code.
Projects
None yet
Development

No branches or pull requests

4 participants