How to add the ApplicationPoolIdentity to a SQL Server Login

The ApplicationPoolIdentity is a virtual account in Windows that is dynamically generated when the application pools is created and takes on the name of the application pool in this manner: IIS Apppool\<name of application pool> . For instance, the application pool MyApp would have a virtual account created under the name IIS Apppool\MyApp when instantiated. Read here for more information about the ApplicationPoolIdentity and here for Windows virtual accounts.

Since Windows is creating a dynamic virtual account for the application pool, there is not set identity or Windows user account to assign to a SQL login for data access. This makes it difficult to assign the application pool to the SQL login. This blog post shows how to add a SQL login for local and a remote SQL Server to allow the applications hosted in an application pool to access the SQL Server.

Side note: The IIS authentication method, anonymous or Windows, will not make a difference on the access to the SQL Server. The security principle used to connect to the SQL Server is the one setup in the application pool configuration Identity.

On a local SQL Server, the login request will appear as the IIS application pool identity. For instance, if the application pool is called AuthTest, the login will appear as IIS Apppool\AuthTest.

On a remote SQL Server, the login request will appears as the machine name since the built in account is attempting to access SQL. For example, the server IIS01 will appear as domain\IIS01$ in a SQL trace.

To validate the connection to SQL, run a SQL trace with the Audit Login Failed and User Error Message events enabled and this will show the account attempting to access SQL. Or, check the SQL log files.

To Add the Account to SQL:

The steps are the same to add the login to SQL for a local or remote SQL Server. However, the identities are different depending on the server if SQL Server is installed locally or on a remote server.

For a local SQL Server:

  • Open SQL Server Management Studio (SSMS) and connect to the SQL Server.
  • Open the Security folder at the server level and not the security folder for the database.
  • Right click on the logins and select New Login.
  • For the login, type IIS APPPOOL\AppPoolName and DO NOT CLICK SEARCH and select OK (If a search is executed, it will resolve to an account with ServerName\AppPool Name and SQL will be unable to resolve the account’s SID since it is virtual)
  • Select the defaults for the account and select OK to close dialog

The same can be accomplished using T-SQL:

CREATE LOGIN [IIS APPPOOL\AuthTest] FROM WINDOWS;
CREATE USER AuthTest FOR LOGIN [IIS APPPOOL\AuthTest];

For a remote SQL Server:

  • Open SQL Server Management Studio (SSMS) and connect to the SQL Server.
  • Open the Security folder at the server level and not the security folder for the database.
  • Right click on the logins and select New Login.
  • For the login, type Domain\ServerName$ and DO NOT CLICK SEARCH
  • Select OK
  • Select the defaults for the account and select OK to close dialog

Using T-SQL:

CREATE LOGIN [computername$] FROM WINDOWS;

web.config SET integrated security=SSPI;

时间: 2024-08-01 21:39:17

How to add the ApplicationPoolIdentity to a SQL Server Login的相关文章

SQL Server &quot;Login failed for user &#39;xxx\yyy&#39;. [SQLSTATE 28000] (Error 18456). &quot; 问题解决

问题:SQL Server 2014,使用Job定时从Linked Server同步数据,执行时报"Login failed for user '域帐号'. [SQLSTATE 28000] (Error 18456). " 解决:通过配置管理工具修改SQL Server Agent服务启动帐号为域帐号,参见: Login failed for [SQLSTATE 28000] (Error 18456) the step failed SQL Server "Login f

SQL Server login failed

http://www.midifan.com/moduleuser-index-411202.htmhttp://www.midifan.com/moduleuser-index-411236.htmhttp://www.midifan.com/moduleuser-index-411259.htmhttp://www.midifan.com/moduleuser-index-411289.htmhttp://www.midifan.com/moduleuser-index-411178.htm

Configure Always On Availability Group for SQL Server on Ubuntu

下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭建两种类型的SQL Server AG,一种是高可用性的结构同时使用Cluster服务器提供业务连续性.这种结构包括read-scale节点.接下来就会介绍这种AG的搭建方法.另外一种是没有Cluster服务的read-scale AG,这种结构仅仅提供只读的可扩展性,不提供高可用性功能.关于如何创

Microsoft SQL Server Version List(SQL Server 版本)

原帖地址 What version of SQL Server do I have? This unofficial build chart lists all of the known Service Packs (SP), Cumulative Updates (CU), patches, hotfixes and other builds of MS SQL Server 2014, 2012, 2008 R2, 2008, 2005, 2000, 7.0, 6.5 and 6.0 tha

Configure Always On Availability Group for SQL Server on RHEL——Red Hat Enterprise Linux上配置SQL Server Always On Availability Group

下面简单介绍一下如何在Red Hat Enterprise Linux上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 之前发表过一篇类似的文章是Configure Always On Availability Group for SQL Server on Ubuntu——Ubuntu上配置SQL Server Always On Availability Group,有对Ubuntu感兴趣的请看那一篇

linux+asp.net core+nginx+sql server

Linux Disibutaion:Ubuntu 16.04.1 LTS Web Server:Nginx.Kestrel 安装.net core sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list' sudo apt-key adv --key

Sql Server来龙去脉系列之四 数据库和文件

在讨论数据库之前我们先要明白一个问题:什么是数据库? 数据库是若干对象的集合,这些对象用来控制和维护数据.一个经典的数据库实例仅仅包含少量的数据库,但用户一般也不会在一个实例上创建太多的数据库.一个数据库实例最多能创建32767个数据库,但是按照实际情况,一般设计是不会达到这个限制值. 为了更明显地说明数据库,数据库包含了以下属性和功能: *. 它是很多对象的集合,比如表.视图.存储过程.约束.对象集合的最大值是2(31) - 1(超过2百亿).一般对象的数量在几百至一万. *. 它维持拥有的用

SQL Server 默认跟踪 -- 捕获事件详解

SQL Server 默认跟踪 -- 捕获事件详解 哪些具体事件默认跟踪文件能够捕获到? --returns full list of events SELECT * FROM sys.trace_events --returns a full list of categories SELECT * FROM sys.trace_categories --returns a full list of subclass values SELECT * FROM sys.trace_subclass

SQL Server遗失管理权限账号密码怎么办?

原文:SQL Server遗失管理权限账号密码怎么办? 假如一个SQL Server实例只允许"SQL身份认证"模式登录数据库,而糟糕的是你忘记了sa的密码(sa出于安全考虑应该被禁用,这里仅仅为了描述问题)或其它具有sysadmin角色的登录名的密码?个人就遇到这样一个案例,HK一同事在一台测试服务器安装了一个测试用途的SQL Server数据库,然后这个同事离职前没有交接这个测试服务器任何信息.那现在就麻烦了.我没有任何权限,我如何获取sysadmin的权限呢?或者还有比较多的场景