【问题标题】:SQL Server: Find out which users have write access to which tables?SQL Server:找出哪些用户对哪些表具有写权限?
【发布时间】:2009-10-15 17:55:54
【问题描述】:

在 SQL Server 7.0 中,我需要找出哪些用户对特定数据库中的哪些表具有写入权限。

我知道我可以在企业管理器中执行此操作,方法是遍历数据库中的每个表并查看授予这些表的访问权限 - 但数据库中有几百个表。由于我只关心少数用户,我宁愿从用户那里接近它。

有没有可以在系统表上运行的查询来实现这一点?通过 Enterprise Manager 是否有其他方法?

我所追求的基本上是这样的:

UserOne has write access to Table1, Table2 and Table3
UserTwo has write access to Table2 and Table3
etc.

【问题讨论】:

    标签: sql-server database-permissions


    【解决方案1】:
    SELECT u.name, o.name
    FROM syspermissions p, sysobjects o, sysusers u
    WHERE p.id = o.id
    AND u.uid = p.grantee
    AND u.name IN ('UserOne', 'UserTwo', 'UserThree')
    AND o.xtype = 'U'
    AND p.actadd = 27
    

    magic 27 由 1 (SELECT) + 2 (UPDATE) + 8 (INSERT) + 16 (DELETE) 构建而成

    感谢 Matt Lacey(和 Google!)让我走上了正确的道路:http://blog.mrlacey.co.uk/2007/06/checking-database-permissions-in-sql.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-20
      相关资源
      最近更新 更多