I'd like to use a hashed password with WindowsIdentity
.
My Code is like:
IntPtr windowsUser = IntPtr.Zero;
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool LogonUser(
String lpszUsername, String lpszDomain, String lpszPassword,
int dwLogonType, int dwLogonProvider, out IntPtr windowsUser);
public MainWindow()
{
IntPtr userToken = IntPtr.Zero;
bool success = LogonUser("Username", " ", "Password", 2, 0, out userToken);
if (!success)
return;
WindowsIdentity newIdentity = new WindowsIdentity(userToken);
using (newIdentity.Impersonate())
{
// do something
}
}
Is there any function to use WindowsIdentity
with a hashed password?
I don't want the password to be transmitted in clear text.
Thanks!