class Class_Login
{
//protected bool fun_AuthDomainUser(string userid, string domain, string passwd)
public bool fun_AuthDomainUser(string userid, string domain, string passwd)
{
const int LOGON32_LOGON_INTERACTIVE = 2; //通過網絡驗證賬戶合法性
const int LOGON32_PROVIDER_DEFAULT = 0; //使用默認的Windows 2000/NT NTLM驗證方
IntPtr tokenHandle = new IntPtr(0);
tokenHandle = IntPtr.Zero;
bool checkok = LogonUser(userid, domain, passwd, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle);
return checkok;
}
[DllImport("advapi32.dll")]
private static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
}