【发布时间】:2018-02-15 16:21:16
【问题描述】:
我需要获取所有组名及其描述(其中用户是成员以及那些没有用户的组)。与外部域的连接必须通过端口 389 和用户凭据的 LDAP。
现在我可以使用以下代码验证用户:
public string UserValidation(string username, string domain, string password, string url)
{
var credentials = new NetworkCredential(username, password, domain);
var serverId = new LdapDirectoryIdentifier(url);
LdapConnection connection = new LdapConnection(serverId, credentials);
string result = "true";
try
{
connection.Bind();
}
catch (Exception e)
{
result = e.ToString();
}
connection.Dispose();
return result;
}
此link 有助于获取群组,但不适用于外部域。
【问题讨论】: