.net core设置AD登陆验证

.net core设置AD登陆验证

安装nuget包,using System.DirectoryServices

        public bool TryADAuthenticate(string path, string userName, string password)
        {
            bool isLogin = false;
            try
            {
                DirectoryEntry entry = new DirectoryEntry(path, userName, password);
                entry.RefreshCache();
                isLogin = true;
            }
            catch
            {
                isLogin = false;
            }
            return isLogin;
        }
posted @ 2022-03-18 15:12  亘古不变  阅读(14)  评论(0)    收藏  举报  来源