SQL Server Credentials

Credentials 包含访问 SQL Server Instance 以外的资源所需要的验证信息,大多少Credentials 都包含一个 Windows 用户名和密码。

如果以SQL Server 验证方式创建Login,并将该Login隐射到Credentials,那么该Login能够通过存储在Credentials中的验证信息访问到 SQL Server 实例外部的资源。Credentials是访问资源的中介,通过授予Credentials访问资源的权限,能够集中管理资源访问的权限。在SQL Server中,只需要将Login(Windows Login 或 SQL Server Login)隐射相应的Credentials,就使该Login拥有访问相应资源的权限。

1,创建Credentials的语法

Identity 指定Credentials包含的Account,Secret指定password。

CREATE CREDENTIAL credential_name
WITH IDENTITY = ‘identity_name‘
    [ , SECRET = ‘secret‘ ]
        [ FOR CRYPTOGRAPHIC PROVIDER cryptographic_provider_name ]

IDENTITY =identity_name

Specifies the name of the account to be used when connecting outside the server.

SECRET =secret

Specifies the secret required for outgoing authentication. This clause is optional.

Remarks

When IDENTITY is a Windows user, the secret can be the password. The secret is encrypted using the service master key. If the service master key is regenerated, the secret is re-encrypted using the new service master key.

After creating a credential, you can map it to a SQL Server login by using CREATE LOGIN or ALTER LOGIN. A SQL Server login can be mapped to only one credential, but a single credential can be mapped to multiple SQL Server logins.

If there is no login mapped credential for the provider, the credential mapped to SQL Server service account is used.

A login can have multiple credentials mapped to it as long as they are used with distinctive providers. There must be only one mapped credential per provider per login. The same credential can be mapped to other logins.

2,创建Credentials,并Mapping到SQL Server Login

一个SQL Server Login只能Map到一个Credentials,多个Login能够Map到同一个Credentials。

CREATE CREDENTIAL AlterEgo
WITH IDENTITY = ‘Mary5‘,
    SECRET = ‘<EnterStrongPasswordHere>‘;
/* Modify the login to assign a non cryptographic provider credential */
ALTER LOGIN Login1
WITH CREDENTIAL = AlterEgo;
GO

3,Login 和 Credentials的区别

在SQL Server中,Login用于登陆SQL Server Instance。虽然Login有权限登陆SQL Server Instance,但是不具有访问SQL Server Instance之外的资源的权限。而Credentials用于访问SQL Server Instance以外的资源,将Login映射到Credentials,Login就能通过Credentials存储的域账户访问SQL Server Instance之外的资源。

Appendix:

1,引用《Security Questions: Logins, Credentials, and Proxies》:

  • Login: A login is any principal that is granted access to a SQL Server instance.  The access can be granted to domain users, domain group, or SQL Server authenticated accounts.
  • Credential: A credential provides a mechanism to store login information for a domain account within SQL Server.  The credential can then be used to pass that authentication information from into another login or a proxy to grant it permissions to resources external to SQL Server.

Credentials get brought in when permissions from domain users need to be granted to accounts or services that wouldn’t usually have those permissions.  For instance, if an assembly required EXTERNAL_ACCESS, those permissions could be granted through the use of a credential.  Credentials can also be used to grant SQL Authentication accounts access to external resources.

2,引用《Credentials (Database Engine)》:

A credential is a record that contains the authentication information (credentials) required to connect to a resource outside SQL Server. This information is used internally by SQL Server. Most credentials contain a Windows user name and password.

The information stored in a credential enables a user who has connected to SQL Server by way of SQL Server Authentication to access resources outside the server instance. When the external resource is Windows, the user is authenticated as the Windows user specified in the credential. A single credential can be mapped to multiple SQL Server logins. However, a SQL Server login can be mapped to only one credential.

System credentials are created automatically and are associated with specific endpoints. Names for system credentials start with two hash signs (##).

参考doc:

Credentials (Database Engine)

CREATE CREDENTIAL (Transact-SQL)

Security Questions: Logins, Credentials, and Proxies

时间: 2024-10-08 21:03:04

SQL Server Credentials的相关文章

How to automatic process SSAS cube using SQL Server agent job

How to automatic process SSAS cube using SQL Server agent job After connecting to the Analysis Server, right click on the Cube and select Process When the process window opens, click the dropdown by Script and select Script Action to Clipboard. Then

Invalid object name ‘sys.configurations’. (Microsoft SQL Server, Error: 208)

http://blogs.msdn.com/b/ramaprasanna/archive/2009/09/16/invalid-object-name-sys-configurations-microsoft-sql-server-error-208.aspx ---------- When you use Microsoft SQL Server Management Studio 2008 to access SQL Azure, if you get the following error

管理SQL Server AlwaysOn(1)——基础维护

本文属于管理SQL Server AlwaysOn系列文章 前言: 前面系列已经介绍了SQL Server AlwaysOn的知识点.安装演示及注意事项等.但是这并不是终点,更多的反而是起点.就像不能生了孩子就不管,你还得养(管理).作为DBA,更多的工作内容恰恰就是管理AlwaysOn.所以这里单独列出一个系列介绍SQL Server AlwaysOn的管理.本系列沿用从0开始部署基础的AlwaysOn 的环境. 在这个系列中,准备讲述以下内容: 管理SQL Server AlwaysOn(1

SQL Server中的CLR编程——用.NET为SQL Server编写存储过程和函数

原文:SQL Server中的CLR编程--用.NET为SQL Server编写存储过程和函数 很早就知道可以用.NET为SQL Server2005及以上版本编写存储过程.触发器和存储过程的,不过之前开发的系统要么因为历史原因用的是SQL2000要么根本用不着在SQL Server中启用CLR,所以一直没有尝试.最近因为项目的原因,在这方面做了一个调研,现在在这里分享一下心得. 首先要说明的是要在SQL Server中启用CLR必须是在SQL Server2005及以上版本,其次在默认情况下是

使用Powershell管理Linux 下的 SQL Server

我们上一篇文章介绍了在Centos 7.3下安装及配置 SQL Server,今天我们主要介绍的是如何在Windows下使用Powershell来管理Linux下的SQL Server,其实说到Powershell大家都已经很熟悉了,Powershell不止是命令集合也是批量程序,可以很好的协助管理员提高日常的运维工作,但是微软的Powershell有一个毛病就是不同的服务需要安装不同的Powershell,对于Lync下的Shell.Exchange Shell和系统自带的Powershell

使用PowerShell 命令集进行SQL Server 2012 备份和还原

最近心相不错,所以打算翻译一些英文文档做福利,原文在此,翻译有不足的地方还请各位兄弟指点. 讨论什么是DBA最重要的工作的时候,你最常听到就是一条就是DBA只要做好备份和恢复.事实如此,如果你不做备份,或者无法保证你的备份能够有效恢复,你和你的公司就会处于数据丢失危险下. T-SQL 命令BACKUP DATABASE已经使用了相当长的一段时间(在这之前用的是DUMP DATABASE 命令,老人们都记得). 它仍然不失为备份数据库好方式.我们现在有一个新的方法来自动的做这些日常的备份处理任务.

sql server 导出数据到 Azure Hbase / Hive 详细步骤

The Hadoop on Azure Sqoop Import Sample Tutorial Table of Contents Overview Goals Key technologies Setup and Configuration Tutorial How to set up a SQL database How to use Sqoop from Hadoop on Azure to import SQL Database query results to the HDFS cl

配置SQL Server 2008 R2 Reporting Services

原文:配置SQL Server 2008 R2 Reporting Services 记录如何在本地配置SQL Server 2008 R2 Reporting Services,笔者环境为Windows 7 64位 + SQL Server 2008 R2 一.准备工作 其实准备工作很简单,只需通过Microsoft SQL Server 2008 R2 -> Configuration Tools -> SQL Server Configuration Manager 打开几个Window

[SQL in Azure] Provisioning a SQL Server Virtual Machine on Azure

http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-provision-sql-server/ Provisioning a SQL Server Virtual Machine on Azure The Azure virtual machine gallery includes several images that contain Microsoft SQL Server. You can sel