From: Oleg Nikulin <owl2@etersoft.ru> --- dlls/taskschd/task.c | 23 +++++++++++++++++++---- dlls/taskschd/tests/scheduler.c | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/dlls/taskschd/task.c b/dlls/taskschd/task.c index 6dcec44e8dc..46e0762f515 100644 --- a/dlls/taskschd/task.c +++ b/dlls/taskschd/task.c @@ -2402,6 +2402,7 @@ typedef struct IPrincipal IPrincipal_iface; LONG ref; BSTR user_id; + TASK_LOGON_TYPE logon_type; } Principal; static inline Principal *impl_from_IPrincipal(IPrincipal *iface) @@ -2543,14 +2544,27 @@ static HRESULT WINAPI Principal_put_UserId(IPrincipal *iface, BSTR user_id) static HRESULT WINAPI Principal_get_LogonType(IPrincipal *iface, TASK_LOGON_TYPE *logon_type) { - FIXME("%p,%p: stub\n", iface, logon_type); - return E_NOTIMPL; + Principal *principal = impl_from_IPrincipal(iface); + + TRACE("%p,%p\n", iface, logon_type); + + if (!logon_type) return E_POINTER; + + *logon_type = principal->logon_type; + return S_OK; } static HRESULT WINAPI Principal_put_LogonType(IPrincipal *iface, TASK_LOGON_TYPE logon_type) { - FIXME("%p,%u: stub\n", iface, logon_type); - return E_NOTIMPL; + Principal *principal = impl_from_IPrincipal(iface); + + TRACE("%p,%u\n", iface, logon_type); + + if (logon_type == TASK_LOGON_NONE) + return E_INVALIDARG; + + principal->logon_type = logon_type; + return S_OK; } static HRESULT WINAPI Principal_get_GroupId(IPrincipal *iface, BSTR *group_id) @@ -2610,6 +2624,7 @@ static HRESULT Principal_create(IPrincipal **obj) principal->IPrincipal_iface.lpVtbl = &Principal_vtbl; principal->ref = 1; principal->user_id = NULL; + principal->logon_type = TASK_LOGON_INTERACTIVE_TOKEN; *obj = &principal->IPrincipal_iface; diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c index 705ba478471..27bb20c85c8 100644 --- a/dlls/taskschd/tests/scheduler.c +++ b/dlls/taskschd/tests/scheduler.c @@ -1798,6 +1798,33 @@ static void test_principal(IPrincipal *principal) hr = IPrincipal_get_UserId(principal, &bstr); ok(hr == S_OK, "get_UserId failed: %08lx\n", hr); ok(bstr == NULL, "expected NULL, got %s\n", wine_dbgstr_w(bstr)); + + hr = IPrincipal_get_LogonType(principal, NULL); + ok(hr == E_POINTER, "expected E_POINTER, got %#lx\n", hr); + + logon_type = 0xdeadbeef; + hr = IPrincipal_get_LogonType(principal, &logon_type); + ok(hr == S_OK, "get_LogonType failed: %08lx\n", hr); + ok(logon_type == TASK_LOGON_INTERACTIVE_TOKEN, "expected TASK_LOGON_INTERACTIVE_TOKEN, got %u\n", logon_type); + + hr = IPrincipal_put_LogonType(principal, TASK_LOGON_NONE); + ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#lx\n", hr); + + hr = IPrincipal_put_LogonType(principal, TASK_LOGON_PASSWORD); + ok(hr == S_OK, "put_LogonType failed: %08lx\n", hr); + + logon_type = 0xdeadbeef; + hr = IPrincipal_get_LogonType(principal, &logon_type); + ok(hr == S_OK, "get_LogonType failed: %08lx\n", hr); + ok(logon_type == TASK_LOGON_PASSWORD, "expected TASK_LOGON_PASSWORD, got %u\n", logon_type); + + hr = IPrincipal_put_LogonType(principal, TASK_LOGON_INTERACTIVE_TOKEN); + ok(hr == S_OK, "put_LogonType failed: %08lx\n", hr); + + logon_type = 0xdeadbeef; + hr = IPrincipal_get_LogonType(principal, &logon_type); + ok(hr == S_OK, "get_LogonType failed: %08lx\n", hr); + ok(logon_type == TASK_LOGON_INTERACTIVE_TOKEN, "expected TASK_LOGON_INTERACTIVE_TOKEN, got %u\n", logon_type); } static void test_TaskDefinition(void) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11065