checking database permissions from master

  • hi

    i need to run a script on all databases on a server, the user i want to use doesnt have access to some of the databases

    i get the error

    The server principal "username" is not able to access the database "database name" under the current security context.

    i have tried to use the tables sys.database_permissions and sys.database_principals but i dont have permissions to use those either

    is there a way of checking permissions of a database from the master database? or is there another way of checking permissions?

    thanks in advance

  • bump?

    if there was a way to add sysusers to sysdatabases in the master database that would help?

    thanks

  • I'm afraid, you need to be in 'sysadmin' role to do that. Check 'print user_name()' and see what permissions that login has.

  • I've come across this a few times and it's usually down to the authentication process.

    Can you ask them to run the following code themselves (assuming they have access via SSMS) ?

    SELECT DISTINCT lt.name FROM sys.login_token lt INNER JOIN sys.server_principals sp ON sp.sid=lt.sid

    That'll tell you which login details they're using to get authenticated, and there could well be a mismatch somewhere.

    [font="Courier New"]sqlmunkee[/font]
    [font="Courier New"]Bringing joy and happiness via SQL Server since 1998[/font]

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

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