C#域验证的代码

来源:互联网 发布:matlab的分块矩阵运算 编辑:程序博客网 时间:2024/05/22 12:46
using System.Runtime.InteropServices;
  
protectedbool fun_AuthDomainUser(stringusername, stringdomain, stringpasswd)
    {
        constint LOGON32_LOGON_INTERACTIVE = 2;//通过网络验证账户合法性
        constint LOGON32_PROVIDER_DEFAULT = 0;//使用默认的Windows 2000/NT NTLM验证方
        IntPtr tokenHandle =new IntPtr(0);
        tokenHandle = IntPtr.Zero;
  
        boolcheckok = LogonUser(username, domain, passwd, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,ref tokenHandle);
        returncheckok;
    }
  
    [DllImport("advapi32.dll")]
    privatestatic externbool LogonUser(stringlpszUsername, stringlpszDomain, stringlpszPassword, intdwLogonType, intdwLogonProvider, refIntPtr phToken);
原创粉丝点击