public static TokenHandle Logon(string username, string domain, string password, UserLogonType logonType = UserLogonType.Interactive, UserLogonProvider logonProvider = UserLogonProvider.Default) { TokenHandle tokenHandle; if (!NativeMethods.LogonUser(username, domain, password, logonType, logonProvider, out tokenHandle)) { ErrorHelper.ThrowCustomWin32Exception(); } return tokenHandle; }
public static TokenHandle Logon(string username, string domain, SecureString password, UserLogonType logonType = UserLogonType.Interactive, UserLogonProvider logonProvider = UserLogonProvider.Default) { IntPtr passwordPtr = Marshal.SecureStringToGlobalAllocUnicode(password); try { TokenHandle tokenHandle; if (!NativeMethods.LogonUser(username, domain, passwordPtr, logonType, logonProvider, out tokenHandle)) { ErrorHelper.ThrowCustomWin32Exception(); } return tokenHandle; } finally { Marshal.ZeroFreeGlobalAllocUnicode(passwordPtr); } }
public IToken Logon(string username, string domain, SecureString password, UserLogonType logonType = UserLogonType.Interactive, UserLogonProvider logonProvider = UserLogonProvider.Default) { var handle = TokenHandle.Logon(username, domain, password, logonType, logonProvider); return new Token(handle); }
public static extern bool LogonUser(string username, string domain, string password, UserLogonType logonType, UserLogonProvider logonProvider, out TokenHandle handle);
public static TokenHandle Logon(string username, string domain, string password, UserLogonType logonType = UserLogonType.Interactive, UserLogonProvider logonProvider = UserLogonProvider.Default) { TokenHandle tokenHandle; if (!NativeMethods.LogonUser(username, domain, password, logonType, logonProvider, out tokenHandle)) { ErrorHelper.ThrowCustomWin32Exception(); } return(tokenHandle); }
public static TokenHandle Logon(string username, string domain, SecureString password, UserLogonType logonType = UserLogonType.Interactive, UserLogonProvider logonProvider = UserLogonProvider.Default) { IntPtr passwordPtr = Marshal.SecureStringToGlobalAllocUnicode(password); try { TokenHandle tokenHandle; if (!NativeMethods.LogonUser(username, domain, passwordPtr, logonType, logonProvider, out tokenHandle)) { ErrorHelper.ThrowCustomWin32Exception(); } return(tokenHandle); } finally { Marshal.ZeroFreeGlobalAllocUnicode(passwordPtr); } }
public IToken Logon(string username, string domain, SecureString password, UserLogonType logonType = UserLogonType.Interactive, UserLogonProvider logonProvider = UserLogonProvider.Default) { var handle = TokenHandle.Logon(username, domain, password, logonType, logonProvider); return(new Token(handle)); }