久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 PrincipalSearcher 查找?guī)в小盎?quot;的用戶參數(shù)

Using PrincipalSearcher to find users with quot;orquot; parameters(使用 PrincipalSearcher 查找?guī)в小盎虻挠脩魠?shù))
本文介紹了使用 PrincipalSearcher 查找?guī)в小盎?quot;的用戶參數(shù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

是否可以使用 System.DirectoryServices.AccountManagement.PrincipalSearcher 使用或"(而不是和")基于多個(gè)參數(shù)進(jìn)行搜索.

Is it possible to use System.DirectoryServices.AccountManagement.PrincipalSearcher to search based on multiple parameters using "or" (not "and").

// This uses an and
//(&(objectCategory=person)(!UserAccountControl:1.2.840.113556.1.4.803:=2)(&(SAMAccountName=tom*)(DisplayName=tom*)))
var searchPrinciple = new UserPrincipal(context);
searchPrinciple.DisplayName =  "tom*";
searchPrinciple.SamAccountName = "tom*";

var searcher = new PrincipalSearcher();
searcher.QueryFilter = searchPrinciple;

var results = searcher.FindAll();

我想使用 PrincipalSearcher(不是 DirectorySearcher)

// (&(objectCategory=person)(!UserAccountControl:1.2.840.113556.1.4.803:=2)(|(SAMAccountName=tom*)(DisplayName=tom*)))

推薦答案

這顯然是不可能的,這里有一個(gè)解決方法:

It's obviously not possible, here is a workaround:

List<UserPrincipal> searchPrinciples = new List<UserPrincipal>();
searchPrinciples.Add(new UserPrincipal(context) { DisplayName="tom*"});
searchPrinciples.Add(new UserPrincipal(context) { SamAccountName = "tom*" });
searchPrinciples.Add(new UserPrincipal(context) { MiddleName = "tom*" });
searchPrinciples.Add(new UserPrincipal(context) { GivenName = "tom*" });

List<Principal> results = new List<Principal>();
var searcher = new PrincipalSearcher();
foreach (var item in searchPrinciples)
{
    searcher = new PrincipalSearcher(item);
    results.AddRange(searcher.FindAll());
}

這篇關(guān)于使用 PrincipalSearcher 查找?guī)в小盎?quot;的用戶參數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應(yīng)該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒(méi)有更高效的語(yǔ)法?)
How to set null value to int in c#?(如何在c#中將空值設(shè)置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時(shí)如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調(diào)用)
主站蜘蛛池模板: 九九99靖品| 日本一区二区三区四区 | 在线看国产 | 亚洲免费在线 | 天堂va在线观看 | 成年人免费网站 | 欧美日韩在线不卡 | 337p日本欧洲亚洲大胆 | 亚洲精品视频在线看 | 午夜视频在线观看网站 | 97精品超碰一区二区三区 | 可以免费观看的av片 | 国产乱精品一区二区三区 | 久久9精品 | 久久小视频| 成年人黄色一级片 | 欧美一级黄色免费看 | 久久久久久久久久久久久9999 | 黄视频国产 | 国产免费自拍 | 国产精品九九视频 | 色婷婷av777 av免费网站在线 | 91精品国产色综合久久不卡98口 | 午夜精品在线 | 91青青草视频 | 在线免费亚洲视频 | 在线观看亚洲精品视频 | 精品久久久久久一区二区 | 午夜在线| 一区在线视频 | 久久手机视频 | 国产精品污www在线观看 | 久久久久99 | 美女视频黄色的 | 日韩av免费看 | 久久久久国产一区二区三区 | 国产成人午夜精品影院游乐网 | 欧美成人在线影院 | 一级在线观看 | 九九综合九九 | 国产三级大片 |