在 SQL Server 中检查安全组中的用户

在我的数据库的 Security/Users 文件夹中,我有一堆安全组,包括MyApplication Users".我需要检查我(或其他用户)是否在这个组中,但我不知道如何查询它或在哪里可以看到这些信息.我尝试查看属性,但找不到任何内容.有什么想法吗?

In the Security/Users folder in my database, I have a bunch of security groups, include "MyApplication Users". I need to check if I am (or another user is) in this group, but I have no idea how to query for it or where I could see this information. I tried looking in the properties, but couldn't find anything. Any ideas?

推荐答案

检查自己或当前用户:

SELECT IS_MEMBER('[group or role]')

结果 1 = 是,0 = 否,空 = 查询的组或角色无效.

A result of 1 = yes,0 = no, and null = the group or role queried is not valid.

要获取用户列表,请尝试 xp_logininfo,如果启用了扩展 procs 并且有问题的组是 Windows 组:

To get a list of the users, try xp_logininfo if extended procs are enabled and the group in question is a windows group :

EXEC master..xp_logininfo 
@acctname = '[group]',
@option = 'members'

相关文章