MD5 Hash password for WindowsIdentity - C#

时间:2017-06-15 09:30:20

标签: c# windows hash md5 password-protection

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!

0 个答案:

没有答案