.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;
}