Error 5021 creating a “Managed Service Account”

拥有回忆 提交于 2021-01-28 05:35:14

问题


I have spent several days trying to get a "managed service account" set up on Windows Server 2012 for a .NET web app. Let's start with the error and work backwards.

I get the following events ever time I try to access a page on the web site where * is the name of my app pool:

  • Warning 5021 - The identity of application pool * is invalid. The user name or password that is specified for the identity may be incorrect, or the user may not have batch logon rights. If the identity is not corrected, the application pool will be disabled when the application pool receives its first request. If batch logon rights are causing the problem, the identity in the IIS configuration store must be changed after rights have been granted before Windows Process Activation Service (WAS) can retry the logon. If the identity remains invalid after the first request for the application pool is processed, the application pool will be disabled. The data field contains the error number.
  • Warning 5057 - Application pool * has been disabled. Windows Process Activation Service (WAS) did not create a worker process to serve the application pool because the application pool identity is invalid.
  • Error 5059 - Application pool * has been disabled. Windows Process Activation Service (WAS) encountered a failure when it started a worker process to serve the application pool.

~~~

While standing up a new server, I came across what appears to be an awesome feature which I had not used before:

  • http://technet.microsoft.com/en-us/library/dd548356%28v=ws.10%29.aspx

Since I am standing up a new app with a new database, this seemed like the perfect opportunity to take this for a drive!

I eventually figured out how to create the managed service account with the following power shell commands on a domain controller:

  • import-module activedirectory
  • new-ADServiceAccount -SAMACCOUNTname "SERVICE_ACCT$"
  • add-adComputerServiceAccount -Identity SERVER_NAME SERVICE_ACCT$

In the same powershell window, I can list services accounts for a given server with this powershell command:

  • get-ADComputerServiceAccount SERVER_NAME

And my managed service account is there! All good so far ...

I then had to modify our central group policy to include my service account for "Log on as batch job" and "Log on as service". These were under Polices\Windows Settings\Security Settings\Local Policies\User Rights Assignment on our domain controller (these were not editable on the local server as these were being pushed down).

After the changes and a coffee break, the rights show up on my server!

So now I have (1) created a managed service account which has (2) been granted access to a specific server and on that specific server (3) the service account has log on as batch job/service rights. I also (4) gave both the app pool and service account modify access to the web site folder.

I verified the site works with the default AppPoolIdentity account.

And ... I still get the errors above (which I have had during this whole process). I have to be missing something, but I just can find anything else to try!

Regards,

Cooter


回答1:


I had to put this on the shelf for a while, but was eventually able to get this working. The most helpful resource I found was the following YouTube on MSAs.

http://www.youtube.com/watch?v=VNCGSQPhLuM

To summarize, there are quite a few requirements and steps

Domain Requirements:

  • Domain Function Level - Windows Server 2008R2+
  • Run ADPrep/ForestPrep

Client Requirements:

  • Windows Server 2008R2+
  • .Net Framework 3.5
  • Active Directory Module for Windows PowerShell (this gets installed with AD DS, but I was able to excluded all but the module during the process)

Supported Software:

  • IIS - yes (app pools)
  • SQL Server - no

On server where MSA is to be used, navigate to Server Manager - Features - Add features

  • Confirm 3.5 Framework installed
  • Confirm Active Directory Module for Windows PowerShell installed

On any server with AD administration tools, Via PowerShell: NOTE: My MSA is WorkProdDnnIIS and my host is WorkProd2012.

  • C:> import-module activedirectory
  • C:> New-ADServiceAccount -name WorkProdDnnIIS -enable $true
  • C:> Add-AdComputerServiceAccount -Identity WorkProd2012 -ServiceAccount WorkProdDnnIIS

On any server with AD administration tools, via AD Users and Computers

  • the new MSA should be listed under "Managed Service Accounts"

On server on which MSA is to be used, via PowerShell

  • C:> import-module activedirectory
  • C:> Install-AdServiceAccount -Identity WorkProdDnnIIS

On server on which MSA is to be used, via IIS Manager

  • Change App Pool identity (e.g. POWER\WorkProdDnnIIS$ - Dollar sign required on end, leave password blank)

Lastly, the local policy settings to allow "Log on as batch job" and "Log on on as service" are required for the MSA for IIS app pools. I would suspect that the Install-ADServiceAccount would do this, however these changes could not be made locally. I manually edited the group policy on a domain controller to achieve the same end result.

Regards,

Cooter



来源:https://stackoverflow.com/questions/21637547/error-5021-creating-a-managed-service-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!