English 中文(简体)
限制在LDAP查询中归还的属性
原标题:Limiting the attributes returned in an LDAP query

我如何限制通过系统归还的少数群体权利倡议的属性。 名录服务?

我一直在使用一位名录Searcher,并增加了我想要的Searcher的特性。 4. 不动产。 问题在于,这只是确保添加的特性被列入名录。 财产和一些违约清单。 是否有任何办法具体说明你想要归还的唯一财产?

DirectoryEntry base = new DiectoryEntry(rootPath, null, null, AuthenticationTypes.FastBind);
DirectorySearcher groupSearcher = new DirectorySearcher(base);
groupSearcher.Filter = "(objectClass=group)";
groupSearcher.PropertiesToLoad.Add("distinguishedName");
groupSearcher.PropertiesToLoad.Add("description");
foreach (SearchResult groupSr in groupDs.FindAll())
...

在我获得团体名录的旁边,大约有16种不同的财产,我不仅可以接触到我所指明的两种特性(区别,描述)

最佳回答

您重新限定的是您的<代码>上可提供/填满的物品——您可直接查阅<代码>。 住宿:

DirectoryEntry baseEntry = new DirectoryEntry(rootPath, null, null, AuthenticationTypes.FastBind);

DirectorySearcher groupSearcher = new DirectorySearcher(baseEntry);
groupSearcher.Filter = "(objectClass=group)";

groupSearcher.PropertiesToLoad.Add("distinguishedName");
groupSearcher.PropertiesToLoad.Add("description");

foreach (SearchResult groupSr in groupSearcher.FindAll())
{
   if(groupSr.Properties["description"] != null && groupSr.Properties["description"].Count > 0)
   {
      string description = groupSr.Properties["description"][0].ToString();
   }

  .....
} 

您不能将财产限制在实际的<条码>名录上,这样,如果您能够浏览每个条码的目录,你可以完全查阅所有材料。 但整个观点是,你可以界定你需要哪些特性,并查阅<代码>SearchResult上的<>直接,, 不含 , 须回到底线.DirectoryEntry

问题回答

原始答案是正确的,但如果你真的需要使用<条码>目录>,希望获得特定财产,则在获得价值之前,可以通过<条码>重新编号装载:

dirEntry.RefreshCache(new [] { "mail", "displayName" });
var email = (string) dirEntry.Properties["mail"]?.Value;
var displayName = (string) dirEntry.Properties["displayName"]?.Value;

这样,只有“邮件”和“显示”才从这一条目中装载。

更多信息here





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...