For our backup software I'm trying to add a check if the user has enough permissions to create a backup.
When I create a login Test for a database and give it the db_backupoperator role for that database, how do I check for that role?
I tried:
SELECT name as 'DatabaseName', has_dbaccess(name) as 'HasAccess' FROM sys.databases
This is always 0 for each database (except master, tempdb and msdb).
When I do:
SELECT name as 'DatabaseName', HAS_PERMS_BY_NAME(name, 'DATABASE', 'CREATE BACKUP') as 'HasAccess' FROM sys.databases
It results in NULL for each database.
When I do:
SELECT IS_ROLEMEMBER ( 'db_backupoperator')
I get 0 because I probably don't have permissions to view the permission tables even though I know the user has that role assigned.
Any other way?