代碼加注釋:
01
using
System;
02
using
System.Collections.Generic;
03
using
System.Linq;
04
using
System.Text;
05
using
System.Security.Principal;
06
using
System.Runtime.InteropServices;
07
using
System.IO;
08
09
namespace
ConsoleApplication3
10
{
11
internal
static
class
WinLogonHelper
12
{
13
/// <summary>
14
/// 模擬windows登錄域
15
/// http://www.cnblogs.com/yukaizhao/
16
/// </summary>
17
[DllImport(
"advapi32.DLL"
, SetLastError =
true
)]
18
public
static
extern
int
LogonUser(
string
lpszUsername,
string
lpszDomain,
string
lpszPassword,
int
dwLogonType,
int
dwLogonProvider,
ref
IntPtr phToken);
19
}
20
21
class
Program
22
{
23
static
void
Main(
string
[] args)
24
{
25