TaskScheduler icon indicating copy to clipboard operation
TaskScheduler copied to clipboard

UnauthorizedAccessException without credentials

Open splendid25 opened this issue 1 year ago • 2 comments

Describe the bug I'm using the TaskService constructor without any user or password, so it's supposed to use the current user account. The library is not working since the update from 2.10.1 to 2.11.0

Furthermore, the current user account gets locked out after 5 retries, so it seems the user tries to login with a wrong password, but I didn't specify any. It's likely due to this PR ? https://github.com/dahall/TaskScheduler/pull/969

System.UnauthorizedAccessException: Accès refusé. (Exception de HRESULT : 0x80070005 (E_ACCESSDENIED))
at void Microsoft.Win32.TaskScheduler.V2Interop.ITaskService.Connect(in object serverName, in object user, in object domain, in object password)
at void Microsoft.Win32.TaskScheduler.TaskService.Connect()
at new Microsoft.Win32.TaskScheduler.TaskService(string targetServer, string userName, string accountDomain, string password, bool forceV1)

To Reproduce Steps to reproduce the behavior:

var taskService = new TaskService(serverName);

Expected behavior Code working without Exception

Environment (please complete the following information):

  • Host Windows version (the one running the code): Windows Server 2022 and Windows 11 Pro 23H2
  • Library version: 2.11.0
  • Remote Windows version (if applicable): Windows Server 2016

Additional context The current user is admin of the remote server. If I use this, it works fine : var taskService = new TaskService(serverName, myLogin, myDomain, myPassword);

splendid25 avatar May 17 '24 12:05 splendid25

I think I have corrected this in v2.11.1 which is available to pull for testing from AppVeyor. Please let me know if you can apply it and confirm it works for you. My apologies.

dahall avatar May 25 '24 15:05 dahall

Hello, I have the same issue with version 2.11.0. I tested with v2.11.1 and it seems to solve the issue

darkag avatar Aug 06 '24 08:08 darkag

Same issue here, using 2.10.1 for now. Is there an ETA for 2.11.1?

tklemenc avatar Feb 22 '25 08:02 tklemenc

I'm pushing 2.12.0 now with these updates and support for .NET 9

dahall avatar Feb 26 '25 16:02 dahall