LogonUser

C# Signature:

[DllImport("advapi32.dll", SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool LogonUser(
  [MarshalAs(UnmanagedType.LPStr)] string pszUserName,
  [MarshalAs(UnmanagedType.LPStr)] string pszDomain,
  [MarshalAs(UnmanagedType.LPStr)] string pszPassword,
  int dwLogonType,
  int dwLogonProvider,
  ref IntPtr phToken);

VB .NET Signature:

Declare Auto Function LogonUser Lib "advapi32.dll" (ByVal lpszUsername As String, _
   ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As LogonType, _
    ByVal dwLogonProvider As LogonProvider, ByRef phToken As IntPtr) As Integer

VB .NET Signature:

<DllImport("advapi32.dll", SetLastError:=true)> _
   Public Function LogonUser( ByVal lpszUsername as String, _
     ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As LogonType, _
     ByVal dwLogonProvider As LogonProvider, ByRef phToken As IntPtr) As Integer
   End Function

User-Defined Types:

C# User-Defined Types

Sample Code:

Sample Code:

Sample Code in VB.NET:

Última actualización