https://www.cnblogs.com/ahuo/archive/2007/03/16/676853.html
添加引用 System.DirectoryServices
导入命名空间 using System.DirectoryServices;
srvip = "192.168.1.1";
dn = "DC=l,DC=com";
user = @"administrator";
pwd = "123";
DirectoryEntry de;
de= new DirectoryEntry("LDAP://" + srvip + "/" + dn, user, pwd);
DirectorySearcher sr = new DirectorySearcher(de, "(userPrincipalName=" + logname+")"); //要括起来
string path = sr.FindOne().Properties["distinguishedName"][0].ToString();
}
}
}
导入命名空间 using System.DirectoryServices;
dn = "DC=l,DC=com";
CN 用户名
OU 组织
DC 域控制器
userPrincipalName 登录名
}
}
posted @ 收藏
评论列表
导入命名空间 using System.DirectoryServices;
dn = "DC=l,DC=com";
CN 用户名
OU 组织
DC 域控制器
userPrincipalName 登录名
}
}