'Cannot execute as the database principal because the principal "##MS_PolicyEventProcessingLogin##" does not exist


 Couple of day’s back our error log was flooded with below error

Error:The activated proc '[dbo].[sp_syspolicy_events_reader]' running on queue 'msdb.dbo.syspolicy_event_queue' output the following:  'Cannot execute as the database principal because the principal "##MS_PolicyEventProcessingLogin##" does not exist, this type of principal cannot be impersonated, or you do not have permission.’




The error itself says issue is with

  1. login "##MS_PolicyEventProcessingLogin##"
  2. On MSDB database
  3. Issue is permission impersonation
To check our understanding we use below sql

/*************SQL Code Start****************/
USE MSDB
Go
EXEC SP_CHANGE_USERS_LOGIN ‘REPORT’

/*************SQL Code End*****************/

Output: This returns the UserName ##MS_PolicyEventProcessingLogin##

This gives clear understanding that User : ##MS_PolicyEventProcessingLogin##  in MSDB was not mapped with its login.

So the quick fix is remap user with its login using below sql proc

/*************SQL Code Start****************/
exec sp_change_users_login ‘AutoFix’, ‘##MS_PolicyEventProcessingLogin##’
/*************SQL Code End*****************/

Now no more flooding of similar error.

2 comments:

  1. This has really worked for me. Thank you very much Saurabh:) Keep posting some helpful tips and solutions

    ReplyDelete