Context switching - Execute as Login not working

  • I have a simple tsql jop that runs a backup to a network location.

    The active directory login mydomain\backup1 has modify rights to the network location.

    If I run the SQL Agent as mydomain\backup1 the job runs fine. If I run the sql agent as Local System the job fails, which it should.

    Now I added the following to the beginning of the script:

    Execute AS Login = 'mydomain\backup1';

    Print suser_name(); -- to confirm that the current context is mydomain\backup1

    the job still fails, but I see in the job log that the context was switched to mydomain\backup1.

    Is there something more I need to do? this is the first time using context switching.

    Thanks

  • I don't believe that the script is what is executing for the file copy. It's still the SQL Agent service that's running. The EXECUTE AS is a SQL command for inside SQL Server, not for impersonation out on the network.

    I think you can set up a proxy of some sort for the job step.

Viewing 2 posts - 1 through 1 (of 1 total)

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