sql server windows ad role permisions

NeophyteSQL 241 Reputation points
2020-08-28T21:35:16.477+00:00

I would like to grant a specific windows role automatic permissions to be the "dbo" every time a new database is created, can this be accomplished using the model database, thanks

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,963 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 112.7K Reputation points MVP
    2020-09-01T06:57:13.503+00:00

    Yet an alternative is to use a server-level DDL trigger that adds the role to the database when it is created.

    But Tibor makes a good point about databases that are restored on the server. DDL triggers don't fire on RESTORE as recall.


7 additional answers

Sort by: Most helpful
  1. tibor_karaszi@hotmail.com 4,311 Reputation points
    2020-08-31T11:35:41.117+00:00

    And just to clarify: Yes, what Erland say is what I suggested. We are in agreement.

    0 comments No comments

  2. NeophyteSQL 241 Reputation points
    2020-09-01T00:32:40.3+00:00

    thank you.

    are there any recommended ways other than using the model database wherein an AD group can be the member of the db_owner whenever a database is created without explicitly adding the AD role to the db_owner role.

    0 comments No comments

  3. tibor_karaszi@hotmail.com 4,311 Reputation points
    2020-09-01T06:40:59.783+00:00

    Sure, you can have a scheduled job executing, say, every hour. This can do anything you want, for instance go through all databases and verify that the login for this AD group exists as a user in each database an is a member of db_owner role. But you will of course have a lag between the database is created and when the job is executed. However, this is in one aspect more robust than the model database. A database can be "created" by restore or attach. The model database won't help you in those cases.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.