What permissions are required to query master..syslogins in SQL Server?

折月煮酒 提交于 2019-12-12 13:15:58

问题


I have readonly access to the master database however the following query only returns a subset of users. What permissions are needed to return the rest of the users?

SELECT [name] FROM master.dbo.syslogins

回答1:


What version of SQL Server are you on??

The syslogins catalog view has been deprecated with SQL Server 2005 - if you're on 2005 or up, you should use sys.server_principals and sys.sql_logins instead.

When you check the MSDN Books Online topic for sys.server_principals, you'll see a note at the bottom of the page:

In SQL Server 2005 and later versions, the visibility of the metadata in catalog views is limited to securables that a user either owns or on which the user has been granted some permission. For more information, see Metadata Visibility Configuration.

Go to the Metadata Visibility Configuration page to read up on the details of what objects you will be able to see, and how to get access to others.

This note is the most important part if you want to grant permissions:

To allow callers to view metadata, you can grant the callers VIEW DEFINITION permission at an appropriate scope: object level, database level or server level. Therefore, in the previous example, if the caller has VIEW DEFINITION permission on myTable, the stored procedure returns a row.




回答2:


Welcome to "MetaData Visibilty"

In this case, you'll only see the rows associated with you (groups you are a member of for example).

And it's also sys.server_principals now. syslogins is a ancient relic legacy view to SQL Server 7 and earlier (was sysxlogins in SQL Server 2000)

From MSDN for sys.server_principals...

In SQL Server 2005 and later versions, the visibility of the metadata in catalog views is limited to securables that a user either owns or on which the user has been granted some permission. For more information, see Metadata Visibility Configuration.

To see all rows you'll need to GRANT rights.

GRANT VIEW ANY DEFINITION TO ...

or

GRANT VIEW DEFINITION ON LOGIN::xxx TO ...

Or be a "sysadmin"...



来源:https://stackoverflow.com/questions/3164185/what-permissions-are-required-to-query-master-syslogins-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!