mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-31 01:35:11 +02:00
try loading advapi32.dll on machine where sspicli.dll does not presents (#244)
PowerShell/Win32-OpenSSH#965
This commit is contained in:
parent
6861ecaa41
commit
b7ee9e98e8
@ -43,6 +43,7 @@ LogonUserExExWHelper(wchar_t *user_name, wchar_t *domain, wchar_t *password, DWO
|
|||||||
PVOID *profile_buffer, LPDWORD profile_length, PQUOTA_LIMITS quota_limits)
|
PVOID *profile_buffer, LPDWORD profile_length, PQUOTA_LIMITS quota_limits)
|
||||||
{
|
{
|
||||||
wchar_t sspicli_dll_path[MAX_PATH + 1] = { 0, };
|
wchar_t sspicli_dll_path[MAX_PATH + 1] = { 0, };
|
||||||
|
wchar_t advapi32_dll_path[MAX_PATH + 1] = { 0, };
|
||||||
wchar_t system32_path[MAX_PATH + 1] = { 0, };
|
wchar_t system32_path[MAX_PATH + 1] = { 0, };
|
||||||
|
|
||||||
if (!GetSystemDirectoryW(system32_path, _countof(system32_path))) {
|
if (!GetSystemDirectoryW(system32_path, _countof(system32_path))) {
|
||||||
@ -51,14 +52,23 @@ LogonUserExExWHelper(wchar_t *user_name, wchar_t *domain, wchar_t *password, DWO
|
|||||||
}
|
}
|
||||||
wcsncpy_s(sspicli_dll_path, _countof(sspicli_dll_path), system32_path, wcsnlen(system32_path, _countof(system32_path)) + 1);
|
wcsncpy_s(sspicli_dll_path, _countof(sspicli_dll_path), system32_path, wcsnlen(system32_path, _countof(system32_path)) + 1);
|
||||||
wcscat_s(sspicli_dll_path, _countof(sspicli_dll_path), L"\\sspicli.dll");
|
wcscat_s(sspicli_dll_path, _countof(sspicli_dll_path), L"\\sspicli.dll");
|
||||||
|
wcsncpy_s(advapi32_dll_path, _countof(advapi32_dll_path), system32_path, wcsnlen(system32_path, _countof(system32_path)) + 1);
|
||||||
if (hMod == NULL)
|
wcscat_s(advapi32_dll_path, _countof(advapi32_dll_path), L"\\advapi32.dll");
|
||||||
hMod = LoadLibraryW(sspicli_dll_path);
|
|
||||||
|
|
||||||
if (hMod == NULL) {
|
if (hMod == NULL) {
|
||||||
debug3("Failed to retrieve the module handle of sspicli.dll with error %d", GetLastError());
|
hMod = LoadLibraryW(sspicli_dll_path);
|
||||||
|
if (hMod == NULL)
|
||||||
|
debug3("Failed to retrieve the module handle of sspicli.dll with error %d", GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hMod == NULL)
|
||||||
|
hMod = LoadLibraryW(advapi32_dll_path);
|
||||||
|
|
||||||
|
if (hMod == NULL) {
|
||||||
|
debug3("Failed to retrieve the module handle of advapi32.dll with error %d", GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
func = (LogonUserExExWType)GetProcAddress(hMod, "LogonUserExExW");
|
func = (LogonUserExExWType)GetProcAddress(hMod, "LogonUserExExW");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user