Export-DbaLogin: Add -IncludeRolePermissions switch#10196
Open
mbentham wants to merge 1 commit intodataplat:developmentfrom
Open
Export-DbaLogin: Add -IncludeRolePermissions switch#10196mbentham wants to merge 1 commit intodataplat:developmentfrom
mbentham wants to merge 1 commit intodataplat:developmentfrom
Conversation
Add switch to export permissions granted to database roles that the login's database users are members of. By default, Export-DbaLogin scripts role membership (ALTER ROLE ... ADD MEMBER) but not the permissions granted to those roles. The new switch calls Export-DbaDbRole internally for each non-fixed role, appending GRANT/DENY statements to the export script. Works in both ObjectLevel and non-ObjectLevel paths. Tracks dataplat#10037 (do Export-DbaLogin) Co-Authored-By: Claude Opus 4.6 <[email protected]>
Member
|
Should this be default? Feels like it should be default. Whatcha think @ClaudioESSilva and @andreasjordan ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Invoke-ManualPester)Purpose
Export-DbaLogin scripts role membership (ALTER ROLE ... ADD MEMBER) but silently omits the permissions granted to those roles. This means exported scripts can appear complete while missing critical GRANT/DENY statements, causing roles to exist on the target server with no actual permissions.
Approach
Add -IncludeRolePermissions switch that calls Export-DbaDbRole internally for each non-fixed role the login's database user belongs to, appending the role's GRANT/DENY statements to the export script. Implemented in both the ObjectLevel and non-ObjectLevel code paths
Commands to test
Export a login with role permissions included
Export-DbaLogin -SqlInstance sqlserver -Login mylogin -IncludeRolePermissions -PassthruCombined with ObjectLevel
Export-DbaLogin -SqlInstance sqlserver -Login mylogin -ObjectLevel -IncludeRolePermissions -PassthruWithout the switch (should NOT include role GRANT statements - existing behavior unchanged)
Export-DbaLogin -SqlInstance sqlserver -Login mylogin -PassthruNote
Couldnt run Invoke-ManualPester due to missing dependency (PSScriptAnalyzer) but running tests with Invoke-Pester directly ran successfully