Job Problem

  • I currently have a job that executes a stored procedure with a call to xp_sendmail on a remote server.  If I run the procedure from Query Analyzer it works fine.  However when I schedule it as a job it fails with the following error:

    Executed as user: TeamtrackAdmin. Remote access not allowed for Windows NT user activated by SETUSER. [SQLSTATE 42000] (Error 7410).  The step failed.

    I tried using SETUSER to specify as user before the call to xp_send mail and got the following error:

    Executed as user: TeamtrackAdmin. SETUSER permission denied in database 'TeamTrack'. [SQLSTATE 42000] (Error 262).  The step failed.

    At this point i am stuck...

  • Does sqlagent has sysadmin rights?

    Allows a member of the sysadmin fixed server role or db_owner fixed database role to impersonate another user.

    <IMG style="MARGIN-LEFT: 0em" height=11 alt="" src="mk:@MSITStore:\Program%20Files\Microsoft%20SQL%20Server\80\Tools\Books\tsqlref.chm::/Basics/important.gif" width=12 border=0>

    Important  SETUSER is included in Microsoft® SQL Server™ 2000 only for backward compatibility, and its usage is not recommended. SETUSER may not be supported in a future release of SQL Server.

     

    I believe SETUSER isn't supported anymore in SQL 2005

  • When you run a sp from QUERY Analyser it runs with your account.

    When you schedule a job it runs by the owner specified in the general tab on the job. The who the job owner is, and does the owner have sufficient rights?   

    ps Remove SETUSER from the proc.


    Andy.

  • I don't know if it's still the case but a similar thing used to happen if you ran the job yourself as opposed to letting it run as a scheduled job.

    In that case it ran in your security context rather than the account that of the account it was set to use.  This used to cause us a few headaches a couple of years back until we worked out what was happening.

  • It sounds like the SQL Agent might not have a fully functional email account.

    When you run xp_sendmail from QA it runs using your email and domain credentials, when run as a job it uses the SQL Agent credentials.

    Is the SQL Agent using a domain account and has the email profile been set-up right?


    All the best,

    Duncan

  • Hello, I had the same problem. I can solve it of the following way:

    select the job with problems. Go to "properties". Go to "Steps". Select the step, and click "edit".

    In the advanced properties of the step to executing in run as user select "self". 😀

    The agent executes this step as "NT AUTHORITY\SYSTEM".

    it's work for me. 😎

    Greetings from argentina.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply