1

SQL Server 凭据用于允许 SQL Server 用户(不是 Windows 用户)在 SQL Server 之外拥有身份,并使他们能够执行各种任务。

http://technet.microsoft.com/en-us/library/ms189828.aspx站点,可以将凭据添加到(SQL Server)登录,如下所示:

ALTER LOGIN Mary5
ADD CREDENTIAL EKMProvider1;
GO

我的问题是,在系统表/视图中哪里可以看到已分配给给定凭据的登录名/用户?谢谢!

4

3 回答 3

1

我认为类似的东西应该适合你。

SELECT sp.name
FROM sys.server_principals AS sp INNER JOIN sys.credentials AS c 
  ON sp.credential_id = c.credential_id
WHERE c.name = 'YOUR_CREDENTIAL_NAME';

以下是有关 sys.credentials 和 sys.server_principals 目录视图的更多信息:

http://technet.microsoft.com/en-us/library/ms188754.aspx

http://technet.microsoft.com/en-us/library/ms189745.aspx

于 2013-08-14T16:04:36.970 回答
1

Having searched for the answer to the same question and found a useful method which contains mapping between logins and credentials.

Here is my solution:

SELECT c.name FROM sys.server_principal_credentials pc
INNER JOIN sys.credentials c
    ON pc.credential_id = c.credential_id
WHERE principal_id IN 
(
    SELECT principal_id FROM sys.server_principals 
    WHERE name = ORIGINAL_LOGIN()
)

@@VERSION = SQL Server 2008 R2

于 2015-09-09T11:53:38.973 回答
1

就我而言,我需要查看凭据的使用方式和位置,这不仅包括登录,还包括代理。我发现这两个查询一起给了我一个有用的概述:

SELECT c.credential_id, c.name AS Credential_Name, c.credential_identity, p.name AS Proxy_Name, p.enabled, p.description
FROM master.sys.credentials c
LEFT JOIN msdb..sysproxies p
ON  c.credential_id = p.credential_id

SELECT c.credential_id, c.name AS Credential_Name, c.credential_identity, p.name AS Principal_Name, p.type_desc, p.is_disabled, p.default_database_name
FROM master.sys.credentials c
LEFT JOIN master.sys.server_principals p
ON  c.credential_id = p.credential_id

在 SQL 2008 R2 到 2016 上进行了测试。

于 2019-09-24T23:13:04.920 回答