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.
12,985 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 102.7K Reputation points
    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. Erland Sommarskog 102.7K Reputation points
    2020-08-29T09:21:09.867+00:00

    I am not sure what you want to achieve. Exactly what permissions do you want to grant the database owner?

    dbo already has all permissions it needs inside the database. If you want to grant permissions on server level, you cannot arrange this with the model database. Model is a template for new databases, and server-level permissions are stored in the master database.

    Maybe a server-level DDL trigger can be a solution for you.


  2. tibor_karaszi@hotmail.com 4,306 Reputation points
    2020-08-29T11:36:31.317+00:00

    You mean something like adding this login as a user to the model database and making that user a member of the db_owner role?

    0 comments No comments

  3. NeophyteSQL 241 Reputation points
    2020-08-31T01:53:13.33+00:00

    yes, Will that work.

    its not a user, A windows AD group needs dbo access automatically every time a new database is created.

    0 comments No comments

  4. Erland Sommarskog 102.7K Reputation points
    2020-08-31T06:43:34.49+00:00

    If you add the Windows AD group as a user to model and make that AD group member of db_owner in model, that AD group will be member of db_owner in each new database. It will not be dbo, but then again I don't think a group can own a database.

    Keep in mind that if you do this, members of this AD group can also do whatever they want in model.

    0 comments No comments