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

使用 PrincipalSearcher 查找帶有“或"的用戶參數

Using PrincipalSearcher to find users with quot;orquot; parameters(使用 PrincipalSearcher 查找帶有“或的用戶參數)
本文介紹了使用 PrincipalSearcher 查找帶有“或"的用戶參數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

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

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*)))

推薦答案

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

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());
}

這篇關于使用 PrincipalSearcher 查找帶有“或"的用戶參數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語法?)
How to set null value to int in c#?(如何在c#中將空值設置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調用)
主站蜘蛛池模板: 一区视频 | 久久福利社 | 插少妇 | 一级片免费在线观看 | 国产一区二区福利 | 亚洲精品免费在线 | 99精品成人 | 中文日韩欧美 | 精品亚洲一区二区 | 欧美激情成人 | 日韩久久久 | 国产黄色三级 | 国产高清久久 | 黄色在线免费网站 | 一区二区三区免费在线观看 | 日韩理论在线 | 国产欧美日韩视频 | 国产精品久久久久久久久久久久久 | 天天干夜夜拍 | 久久久久久久97 | 天天干天天色天天射 | 99久久精品一区二区成人 | 久久精品视频网 | 国产精品成人免费精品自在线观看 | 国产成人三级一区二区在线观看一 | 黄色在线观看免费 | 糖心vlog精品一区二区 | 国产日韩欧美综合 | 中文在线字幕免费观 | 国产极品在线观看 | 成年网站在线观看 | 999久久久| 日本www视频 | 日日操日日干 | 黄色三级视频 | 麻豆国产一区二区三区四区 | 国产91页 | 911精品国产一区二区在线 | 婷婷激情综合网 | 久久久久国产视频 | 日韩av免费在线播放 |