Run a SQL Server Agent job under another account

  • ON my server, SQL Server Agent runs under the NT AUTHORITY\NETWORK SERVICE account. That's usually just fine and I don't want to change it. However, it means that jobs running under the agent cannot access LAN shares. That's what I would like to do in a new job. I figured I could just use an account that I know has access to the share. What I can't figure out is how to do that. I read some MS doc on setting up proxies, but I can't figure out how to make that work.

    Has anyone done what I'm trying to do? If so, can you give a step-by-step to do it?

  • First you need to create a credential.

    This will typically map to a domain account.

    Next you create a proxy account and you link this to the credential you just created.

    You also need to specify a subsystem for which the proxy will be active. For example: if you want the proxy to execute SSIS packages in a job step, you add the SSIS subsystem.

    Finally, when you create a job step, you can specify the proxy account from the Run As dropdown.

    This job step will now run under the credentials of the proxy account.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck (7/4/2013)


    First you need to create a credential.

    This will typically map to a domain account.

    OK -- did that, no problem!

    Koen Verbeeck (7/4/2013)

    Next you create a proxy account and you link this to the credential you just created.

    .

    Here's where I ran into trouble. I started to create the proxy, and added my just-created credential as a principal. Then I saved the definition. However, I reopened the proxy definition to check my work and the principal I had just added (using the new credential) was gone! No error messages, no pop-ups, no nothing....just gone, baby, gone. Since I thought I was nuts, I did it several more times but always with the same results (I guess I am nuts -- I think that's one of the definitions!)

    Why didn't it save the principal and why didn't it tell me it there was a problem? What can cause this and how do I fix it?

    Koen Verbeeck (7/4/2013)

    You also need to specify a subsystem for which the proxy will be active. For example: if you want the proxy to execute SSIS packages in a job step, you add the SSIS subsystem.

    .

    In my case I'm only going to do shell commands using xp_cmdshell

    Koen Verbeeck (7/4/2013)

    Finally, when you create a job step, you can specify the proxy account from the Run As dropdown.

    This job step will now run under the credentials of the proxy account.

    I set that up, but can't use it because of the "principal" problem. What should I do?

  • You don't need to add the credential as a principal.

    You need to specify the credential in the credential name box.

    See the screenshot in attachment.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 4 posts - 1 through 3 (of 3 total)

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