dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.18k stars 190 forks source link

UnauthorizedAccessException without credentials #990

Open splendid25 opened 2 months ago

splendid25 commented 2 months ago

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):

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);

dahall commented 1 month ago

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.