.NET create scheduled task on server fails with E_ACCESSDENIED

后端 未结 4 858
北荒
北荒 2021-01-06 13:35

I have an ASP.NET website (in C#) that takes in user data and then attempts to create a windows scheduled task. Of course, this works great on the DEV machine, but fails to

相关标签:
4条回答
  • 2021-01-06 14:01

    Are you writing something to the eventlog ? It is possible that your component (which is hosted in IIS i presume ? ) has no access to the write something in the eventlog.

    This is merely a guess ~ a while ago, I've been faced with a similar problem, and I've solved it in this way:

    Click

    0 讨论(0)
  • 2021-01-06 14:05

    Another option is to flash the bios on the server

    0 讨论(0)
  • 2021-01-06 14:06

    Instead of worrying about the ASPNET user permissions, would your internal process allow you to create a machine specific account and supply the credentials there?

    0 讨论(0)
  • 2021-01-06 14:10

    I have been able to solve my particular problem, though not completely. I have still not identified the exact rights needed to create and run scheduled tasks, but the following seems to work:

    1. Add the <identity impersonate="true" /> to the Web.config
    2. Add the IUSR user (which is the user the app will run as using impersonate) to the "Backup Operators" group.

    This gives the application access to the Scheduled Tasks folder so that they can create and run the task.

    We had an additional issue, which was that the tasks were attempting to run as the Local System Account. Unfortunately, only administrators seem to be able to assign the Local System Account as the running user, so we needed to impersonate as an Administrator account, not as a Backup Operator in order to get our code functioning correctly.

    0 讨论(0)
提交回复
热议问题