Grant (permission) on database:: ... where can I see these?

  • If run the following statement:

    use someDB;

    grant select on database::someDB to someuser;

    Is there anywhere I can see this permission using the object explorer?

    If I go to the database user properties > securables tab, it doesn't show up (seems like the highest level shown here is schema).

    If I go to the login properties > securables tab, it also doesn't show up.

    PS: Are these two operations identical?

    use someDB;

    grant select on database::someDB to someuser;

    use someDB;

    grant select to someuser;

  • Hi,

    database user properties > securables tab > Search... > All Object of the types... > Databases > Voila!

    Although I'd look at using the db_datareader database role instead if possible, it's a little more visible.

    Cheers

  • Yeah, this was just a simple example, I actually need to grant select, execute, view definition in this case, and similar more complex permissions in other cases.

    It's a shame these are not easy to see once they have been applied.

  • Not through the GUI, no. But there are various T-SQL statements for interrogating permissions too, e.g.

    select *

    from sys.database_permissions dp

    inner join sys.database_principals p on p.principal_id = dp.grantee_principal_id

    where class_desc = 'DATABASE'

  • It would be advisable to create User-defined Database Roles, add your Database Users to the Roles, and only grant permissions or Fixed Role Membership to those Roles. The Roles will act as containers where you can always go to figure out what a given person can do in a database. If I ever need to add people to db_datareader (I prefer not too but sometimes it makes sense, usually for non-prod or ad hoc reporting) I still do not add Users directly to db_datareader. I add the User to a User-defined Database Role and add that Database Role to db_datareader. This keeps the user-to-role layout flat, i.e. Users can only belong to User-defined Database Roles (I aim for 1 to 1 User to User-defined Role, i.e. each user can only belong to one Role) which eases my auditing tasks and makes it easier to avoid a lot of the multi-role-membership and inherited membership oddities that can arise.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply