为DirectorySearcher.SizeLimit = 1的FindAll()等于FindOne()的DirectoryServices / .NET] [英] is DirectorySearcher.SizeLimit = 1 for FindAll() equal to FindOne() [DirectoryServices/.net]

查看:198
本文介绍了为DirectorySearcher.SizeLimit = 1的FindAll()等于FindOne()的DirectoryServices / .NET]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用.NET的DirectorySearcher从,是这两个语句平等吗?

When using the DirectorySearcher in .net, are these two statements equal?

同时适用于:

Dim ds As New DirectorySearcher
' code to setup the searcher

首先声明

ds.FindOne()

第二条语句

ds.SizeLimit = 1
ds.FindAll()

...但显然这FindOne()返回一个信息搜索结果对象的FindAll()返回一个SearchResultCollection对象

...except obviously that FindOne() returns a SearchResult object and FindAll() returns a SearchResultCollection object

推荐答案

是的,这将是差不多了。

Yes, that would be almost the same.

差不多,因为在.NET 2.0(不知道,如果它被固定在新的版本),该.FindOne()调用曾与内存泄露的一些问题,所以最好的做法是(或曾经)总是使用.FindAll( ),并遍历结果。

Almost, because in .NET 2.0 (not sure if it's been fixed in more recent versions), the .FindOne() call had some issues with leaking memory, so best practice is (or was) to always use .FindAll() and iterate over your results.

马克·

这篇关于为DirectorySearcher.SizeLimit = 1的FindAll()等于FindOne()的DirectoryServices / .NET]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆