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;

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

  1. Ubuntu 下安装 SQL Server 2016初探

    安装步骤参官方 https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-setup-ubuntu 执行命令如下: .Enter supe ...

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

        在讨论数据库之前我们先要明白一个问题:什么是数据库?     数据库是若干对象的集合,这些对象用来控制和维护数据.一个经典的数据库实例仅仅包含少量的数据库,但用户一般也不会在一个实例上创建太多 ...

  3. 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 ...

  4. Ubuntu上配置SQL Server Always On Availability Group(Configure Always On Availability Group for SQL Server on Ubuntu)

    下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭 ...

  5. 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),以及配置过程中遇到的坑的 ...

  6. Ubuntu 安装 SQL Server

    SQL Server现在可以在Linux上运行了!正如微软CEO Satya Nadella说的,"Microsoft Loves Linux",既Windows 10内置的Lin ...

  7. vs2012中使用localdb实例还原一个sql server 2008r2版本的数据库

    use localdb sometime is easy than sql server ,and always use visual studio make you stupid. vs2012中还 ...

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

    假如一个SQL Server实例只允许"SQL身份认证"模式登录数据库,而糟糕的是你忘记了sa的密码(sa出于安全考虑应该被禁用,这里仅仅为了描述问题)或其它具有sysadmin角 ...

  9. Configure Always On Availability Group for SQL Server on Ubuntu——Ubuntu上配置SQL Server Always On Availability Group

    下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭 ...

随机推荐

  1. 【Matplotlib】数据可视化实例分析

    数据可视化实例分析 作者:白宁超 2017年7月19日09:09:07 摘要:数据可视化主要旨在借助于图形化手段,清晰有效地传达与沟通信息.但是,这并不就意味着数据可视化就一定因为要实现其功能用途而令 ...

  2. 〖Android〗arm-linux-androideabi-gdb报 libpython2.6.so.1.0: cannot open shared object file错误的解决方法

    执行: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gdb out/target/p ...

  3. __stdio_common_vsnprintf_s,该符号在函数 _vsnprintf_s_l 中被引用

    在链接 输入里加入:ucrtd.lib

  4. Android——TabHost(标签容器)相关知识总结贴

    android 2.3 r1 中文 api (58) —— TabHost http://www.apkbus.com/android-18911-1-1.html   android中文api (5 ...

  5. JAVA中对List<Map<String,Object>>中的中文汉字进行排序

    转载于:http://blog.csdn.net/flykos/article/details/54631573 参考:http://www.jb51.net/article/88710.htm 本篇 ...

  6. Java Web开发基础零星知识

    1. Web的三个核心标准 万维网的核心标准有三个,分别是URL.HTTP和HTML. URL(统一资源定位符,Universal Resource Locator),为描述Internet上的网页以 ...

  7. Socket网络编程--简单Web服务器(2)

    上一小节通过阅读开源的Web服务器--tinyhttpd.大概知道了一次交互的请求信息和应答信息的具体过程.接下来我就自己简单的实现一个Web服务器. 下面这个程序只是实现一个简单的框架出来.这次先实 ...

  8. Socket网络编程--简单Web服务器(4)

    上一小节已经实现了对图片的传输,接下来就是判断文件是否为js,css,png等格式.我们增加一个函数用于判断格式 int WebServer::get_filetype(char *type,char ...

  9. --save与--save-dev的区别

    --save安装的包会在生产和开发环境中都使用: --save-dev的包只在开发环境中使用,在生产环境中就不需要这个包了,不再打包:

  10. Ubuntu python3 安装pip

    python2:sudo apt-get install python-pip python3:sudo apt-get install python3-pip 切换python2和python3的版 ...