• 验证域用户(C#)


    代码如下:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace MACAddressMgmtApp.ServiceImplementations
    {
        class ValidateUserHelper
        {
    
            private static int LOGon32_LOGon_INTERACTIVE = 2;
            private static int LOGon32_PROVIDER_DEFAULT = 0;
            private static IntPtr tokenHandle = new IntPtr(0);
    
    
            [DllImport("advapi32.dll")]
            private static extern bool LogonUser(string lpszUsername,
                string lpszDomain,
                string lpszPassword,
                int dwLogonType,
                int dwLogonProvider,
                ref IntPtr phToken);
    
    
            public static bool Verify(string userName, string pwd, string domain)
            {
                bool boolResult = false;
                tokenHandle = IntPtr.Zero;
                boolResult = LogonUser(userName, domain, pwd, LOGon32_LOGon_INTERACTIVE, LOGon32_PROVIDER_DEFAULT, ref tokenHandle);
                return boolResult;
            }
    
        }
    }
  • 相关阅读:
    安装图形化界面
    cemtos安装python
    traceback说明
    python常用魔法函数
    python上传文件接口
    文件上传接口
    MongoDB安装与使用
    解决macOS系统向有跳板机的服务器传文件
    mac终端命令sftp
    linux下mysql服务安装
  • 原文地址:https://www.cnblogs.com/QiuTianBaBa/p/6795369.html
Copyright © 2020-2023  润新知