无用?是DirectorySearcher.PropertiesToLoad UseLess? [英] UseLess? Is DirectorySearcher.PropertiesToLoad UseLess?

查看:81
本文介绍了无用?是DirectorySearcher.PropertiesToLoad UseLess?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要进行健全性检查b / c我可能误解了PropertiesToLoad的用途。

有没有其他人注意到无论你添加到DirectorySearcher.PropertiesToLoad中的属性名称数量多少​​,生成的DirectoryEntry PropertiesCollection将包含所有属性,而不仅仅是你告诉它的属性?无论我是否使用PropertiesToLoad,返回的数字(对我来说都是一样的。)
ie:

I need a sanity check b/c maybe i've misunderstood the purpose of PropertiesToLoad.

Has anyone else noticed that regardless of the number of property names you add into DirectorySearcher.PropertiesToLoad, the resulting DirectoryEntry PropertiesCollection will contain all the properties, not just the ones you told it to get? The number returned (for me) is the same whether or not I use PropertiesToLoad.

ie:

使用 (DirectorySearcher searcher = new DirectorySearcher()){
// searcher.CacheResults = false;值没有区别
// searcher.PropertiesToLoad.C​​lear();没有区别
searcher.PropertiesToLoad.Add(" mail" ;
searcher.PropertiesToLoad.Add(" displayName" ;
searcher.Filter = filter;
信息搜索结果结果= searcher.FindOne();
DirectoryEntry entry = result.GetDirectoryEntry();
Console.WriteLine(entry.Properties.Count.ToString());
}
using ( DirectorySearcher searcher = new DirectorySearcher() ) { 
    //searcher.CacheResults = false; value makes no difference 
    //searcher.PropertiesToLoad.Clear(); makes no difference 
    searcher.PropertiesToLoad.Add( "mail" )
    searcher.PropertiesToLoad.Add( "displayName" )
    searcher.Filter = filter; 
    SearchResult result = searcher.FindOne(); 
    DirectoryEntry entry = result.GetDirectoryEntry(); 
    Console.WriteLine( entry.Properties.Count.ToString() ); 

推荐答案

你好!

我现在正在努力阅读AD组中的所有用户名。
在一篇文章中我读到了PropertiesToLoad是一个Readonly属性。要提供要加载的属性,您必须将构造函数发送到DirectorySearcher。

希望这有帮助。

/ / Tomas
Hello!

I am right now struggling with reading all usernames from an AD group.
In a post I read that PropertiesToLoad is a Readonly attribute. To supply what properties to load you have to send in in the constructor to the DirectorySearcher.

Hope this helps.

/Tomas


这篇关于无用?是DirectorySearcher.PropertiesToLoad UseLess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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