本文转自: https://www.cnblogs.com/i-mengli/p/9625551.html
//获取登陆页输入的域账号、密码
string domainIP = "192.168.12.10"; //域IP
string userAccount = "Administrator"; //域账号
string Password = "glyszsuzhou"; //域账号密码
using (DirectoryEntry deUser = new DirectoryEntry(@"LDAP://" + domainIP, userAccount, Password))
{
DirectorySearcher src = new DirectorySearcher(deUser);
src.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" + userAccount + "))";
src.PropertiesToLoad.Add("cn");
src.SearchRoot = deUser;
src.SearchScope = SearchScope.Subtree;
SearchResult result = src.FindOne();
if (result != null)//验证成功
{
DirectoryEntry de = result.GetDirectoryEntry();
string userID = de.Username;
#region 域账号验证通过......Read More>