Search code examples
sql-serverwindowsdomainaccount

COM Error 80020005 Type mismatch in Domain User login


When i run this SQL command in Domain User login, there is

COM Error 80020005

SELECT group_database_id FROM sys.databases WHERE name = N'db5'

When i run the same command in windows local user, it runs sucessfully.

How does the domain User login differs?


Backup failed for Server 'hostname\instancename'. (Microsoft.SqlServer.SmoExtended)

To accomplish this action, set property Devices. (Microsoft.SqlServer.SmoExtended)


Solution

  • Windows local user is likely the account used to install the instance, making it a sysadmin. The domain user likely doesn't have the permissions to access it.

    If the caller of sys.databases is not the owner of the database and the database is not master or tempdb, the minimum permissions required to see the corresponding row are ALTER ANY DATABASE or the VIEW ANY DATABASE server-level permission, or CREATE DATABASE permission in the master database. The database to which the caller is connected can always be viewed in sys.databases.

    By default, the public role has the VIEW ANY DATABASE permission, allowing all logins to see database information. To block a login from the ability to detect a database, REVOKE the VIEW ANY DATABASE permission from public, or DENY the `VIEW ANY DATABASE permission for individual logins.

    MSDN