1

Domain user MyDomain\UserA has a login with a server role of public and is a user of the msdb database with membership in the SQLAgentUserRole.

The user owns a job, Daily Job. When logged in as the user, if I try to view the job properties, I get this error:

Cannot execute as the database principal because the principal "guest" does not exist, this type of principal cannot be impersonated, or you do not have permission. (Microsoft Server, Error: 15517)

If I right click on Jobs and Select New Job... I get the exact same error.

I have even given the user membership in SQLAgentOperatorRole but get the same error.

In all my searching online, the only similar issue I've found is this question on MSDN, which is unanswered.

Any ideas? I'm at a loss here.

4
  • So is d.name NULL in the following query, or populated: select j.name, j.owner_sid, s.name, d.name from msdb.dbo.sysjobs AS j INNER JOIN master.sys.server_principals AS s ON j.owner_sid = s.sid LEFT OUTER JOIN msdb.sys.database_principals AS d ON s.sid = d.sid; Commented Mar 31, 2015 at 17:05
  • @AaronBertrand d.name is populated with MyDomain\UserA Commented Mar 31, 2015 at 17:09
  • Can you give some details about what the job does, what kinds of steps it has, any advanced options, that kind of thing? I'm guessing it has dependencies on databases that this login does not have access to... Commented Mar 31, 2015 at 17:29
  • @AaronBertrand Sure, however, the only reason I don't think that's relevant is that the same error occurs if I simply try to create a new job. There are 3 job. Job one and two have one step (each) which is a CmdExec step. They both call scripts and there is nothing checked on the advanced tab. Job three runs an SSIS package from the File system. It also has nothing checked on the advanced tab. Commented Mar 31, 2015 at 17:31

1 Answer 1

3

I had the same exact problem - I had a new user which wanted to add jobs. I added this user to msdb db and added him to sqlAgentOperatorRole and db_datareader, db_datawriter. Still, when trying to add a new job, the user was getting the same error:

Cannot execute as the database principal because the principal "guest" does not exist, this type of principal cannot be impersonated, or you do not have permission. (Microsoft Server, Error: 15517)

I traced it down and it looks like when trying to add a new job (or doing many other things...) the following query is run:

exec master.dbo.sp_Msdbuserpriv 'serv'

So, obviously I had to add the new user to Master as well:

use master
create user [youNewUser] for login [yourNewUserLogin]
alter user [youNewUser] with default_schema=[dbo]

And now it works like charm...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.