Giter VIP home page Giter VIP logo

sql-server-permissions-manager's Introduction

SQL Server Permissions Manager

SQL Server Permission Manager is a suite of scripts that allows you to take "snapshots" of users and permissions across any or all of the databases on your SQL Server. These snapshots then allow you to:

  • Restore existing user permissions to a previous snapshot
  • Script out permissions for an individual user or all users in a database
  • Create a new user by cloning the permissions of an existing user
  • Remove all users and their permissions from a database
  • Remove a login from the server and all of its permissions from all databases

How It Works

SQL Server Permissions Manager creates a "perms" schema in your database, and creates all of its objects there. Tables are created for storing the permission snapshots, and stored procedures are used for gathering and using the snapshot data.

Installation

Simply run the permissions-manager-install.sql file, specifying which database you want the objects to be created in, and then schedule either the perms.createSnapshot (for a specific database) or perms.snapshotAllDBs (for all databases) Stored Procedure to run on a regular basis (I recommend nightly). On each scheduled run, the Procedure will create a snapshot of the current permissions. Once a snapshot has been created, you can call the other Procedures to use that snapshot.

Stored Procedures

Below is a listing of the stored procedures created by SQL Server Permission Manager, and brief description of what each procedure is used for. More detailed decriptions and examples are in the procedure header comments.

perms.applyPermissions

This stored procedure is used to apply a Permissions Snapshot to a specified database; If a Snapshot ID is specified, it will restore that Snapshot, otherwise it defaults to the most recent Snapshot for the specified database;

perms.clonePermissions

This stored procedure is used to copy all of the permissions from a given user and assign those permissions to another user. It will do this for every database on a server, so if a user has permissions on 3 databases, the new user and permissions will be added to those 3 databases.

perms.createDatabaseSnapshot

This stored procedure is used to create a snapshot of the current permissions in a given database

perms.createServerSnapshot

This stored procedure is used to create a snapshot of the current server level permissions that do not apply to a specific database (ex: sysadmin, securityadmin, etc.)

perms.purgeSnapshots

This stored procedure is used to purge old Permission Snapshots from the database

perms.removeAllUsersFromDB

This stored procedure is used to drop all users from a database. Users that own certificates, and default system users, will not be dropped. Users can be added back using the latest permissions snapshot for that database.

perms.removeLogin

This stored procedure is used to remove a user from all databases, then drop the login for that user. Users that own certificates, and default system users, will not be dropped.

perms.restorePerms

This stored procedure is used to remove all users from a database, then Users will be added back using the specified (or latest) permissions snapshot for that database.

perms.snapshotAllDatabases

This stored procedure is used to create a snapshot of the current permissions in all databases on a server.

perms.snapshotEverything

This stored procedure is used to create a snapshot of the current permissions in all databases on a server, as well as the server level permissions.

sql-server-permissions-manager's People

Contributors

ericcobb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sql-server-permissions-manager's Issues

perms.restorePerms : sp_addrolemember need a parameter @rolename

hi,

i install the script on master db, and exec a perms.snapshotEverything proc, which i assumed all the permissions would be save to a snapshot.

but when i try to
exec perms.restorePerms 'somedb',

error occurs:
โ€˜....sp_addrolemember need a parameter @rolenameโ€™

my sqlserver version is:

Microsoft SQL Server 2019 (RTM-CU14) (KB5007182) - 15.0.4188.2 (X64) Nov 3 2021 19:19:51 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 20.04.3 LTS)

Clone User w/ Password

the Clone user feature does not currently allow you to specify a password for the new user; need to add a "password" parameter to the stored procedure;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.