From 589b6786ff6674cd259bc0483651d4b3c7fda2b5 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Sun, 19 Feb 2017 13:53:37 +0200 Subject: [PATCH] LoginAPI: Added ImpersonateLoggedOnUser method --- SMBLibrary/Win32/Security/LoginAPI.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SMBLibrary/Win32/Security/LoginAPI.cs b/SMBLibrary/Win32/Security/LoginAPI.cs index 096e87b..ad340ce 100644 --- a/SMBLibrary/Win32/Security/LoginAPI.cs +++ b/SMBLibrary/Win32/Security/LoginAPI.cs @@ -29,13 +29,14 @@ namespace SMBLibrary.Win32.Security string lpszPassword, int dwLogonType, int dwLogonProvider, - out IntPtr phToken - ); + out IntPtr phToken); [DllImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] private static extern bool CloseHandle(IntPtr hObject); + [DllImport("advapi32.dll", SetLastError = true)] + public static extern bool ImpersonateLoggedOnUser(IntPtr hToken); + public static bool ValidateUserPassword(string userName, string password, LogonType logonType) { IntPtr token;