在DirectorySearcher中处置不按预期的方式工作
|
我正在尝试连接并执行简单的功能,例如使用C#在Active Directory上进行搜索。但是,我陷入了一个问题。我正在使用DirectorySearcher搜索目录。目录中有许多条目。
这是功能
void RunThis()
{
DirectoryEntry de = new DirectoryEntry();
de.Path = \"LDAP://\" + domainName;
de.Username = username;
de.Password = password;
de.AuthenticationType = AuthenticationTypes.Secure;
DirectorySearcher deSearch = new DirectorySearcher(de);
//Skipping properties to load
try
{
deSearch.SearchScope = SearchScope.Subtree;
SearchResultCollection rescoll = deSearch.FindAll();
deSearch.Dispose();
rescoll.Dispose();
}
catch (Exception obj)
{
System.Console.WriteLine(\"Exception in getting results. {0}\",obj.Message);
}
}
de.Dispose();
} // end of function
这是我精简的示例函数。我可以找到很多帖子,其中指出通过显式调用DirectorySearcher或ResultCollection对象可以解决该问题。
但是,我看到任务使用的内存在不断增加。代码的其他部分没有其他内容。当我评论该功能时,内存使用情况变得稳定。
还有其他人面对这个问题并找到解决方案吗?
PS:而且没有出路。我需要做findall :(
没有找到相关结果
已邀请:
5 个回复
冕偷淮款
语句,例如:
敦肌
怪酞撩匹
哩翔购
茂坦湿床够
语句
这不仅会丢弃ѭ5,而且还会为您清理ѭ1块中的所有其他内容。