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

如何從 C# 中找到活動目錄中的用戶?

How can you find a user in active directory from C#?(如何從 C# 中找到活動目錄中的用戶?)
本文介紹了如何從 C# 中找到活動目錄中的用戶?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我試圖弄清楚如何從 C# 搜索 AD,類似于查找用戶、聯系人和組"在 Active Directory 用戶和計算機工具中的工作方式.我有一個包含組名或用戶名的字符串(通常格式為 firstname middleinitial [if they have one] lastname,但并非總是如此).即使我對組和用戶進行單獨的查詢,我也無法想出一種可以捕獲大多數用戶帳戶的搜索方法.查找用戶、聯系人和組工具幾乎每次都會將它們帶回來.有人有什么建議嗎?

I'm trying to figure out how to search AD from C# similarly to how "Find Users, Contacts, and Groups" works in the Active Directory Users and Computers tool. I have a string that either contains a group name, or a user's name (usually in the format firstname middleinitial [if they have one] lastname, but not always). Even if I do a seperate query for groups vs. users, I can't come up with a way to search that captures most user accounts. The Find Users, Contacts, and Groups tool brings them back almost every time. Anyone have any suggestions?

我已經知道如何使用 DirectorySearcher 類,問題是我找不到可以執行我想要的查詢.cn 和 samaccount 名稱都與此中的用戶名無關,因此我無法搜索這些名稱.拆分并搜索 sn 和 givenName 并沒有像該工具那樣捕獲任何地方.

I already know how to use the DirectorySearcher class, the issue is that I can't find a query that does what I'd like. Neither cn nor samaccount name has anything to do with the user's name in this, so I'm unable to search on those. Splitting things up and searching on sn and givenName doesn't catch anywhere near as much as that tool does.

推薦答案

您使用 .NET 3.5 嗎?如果是這樣 - AD 在 .NET 3.5 中有很棒的新功能 - 查看這篇文章 在 .NET 3.5 中管理目錄安全主體,作者 Ethan Wilanski 和 Joe Kaplan.

Are you on .NET 3.5 ? If so - AD has great new features in .NET 3.5 - check out this article Managing Directory Security Principals in .NET 3.5 by Ethan Wilanski and Joe Kaplan.

其中一個重要的新功能是PrincipalSearcher"類,它應該可以大大簡化在 AD 中查找用戶和/或組的過程.

One of the big new features is a "PrincipalSearcher" class which should greatly simplify finding users and/or groups in AD.

如果您不能使用 .NET 3.5,可以讓您的生活更輕松的一件事稱為歧義名稱解析",它是一種鮮為人知的特殊搜索過濾器,可以一次性搜索幾乎所有與名稱相關的屬性.

If you cannot use .NET 3.5, one thing that might make your life easier is called "Ambiguous Name Resolution", and it's a little known special search filter that will search in just about any name-related attribute all at once.

像這樣指定您的 LDAP 搜索查詢:

Specify your LDAP search query like this:

searcher.Filter = string.Format("(&(objectCategory=person)(anr={0}))", yourSearchTerm)

另外,我建議過濾objectCategory"屬性,因為它是單值的并且在 AD 中默認索引,這比使用objectClass"快很多.

Also, I would recommend filtering on the "objectCategory" attribute, since that's single-valued and indexed by default in AD, which is a lot faster than using "objectClass".

馬克

這篇關于如何從 C# 中找到活動目錄中的用戶?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 的方法調用)
主站蜘蛛池模板: 狠狠干免费视频 | 日皮视频在线观看 | 午夜视频免费看 | 色哟哟入口国产精品 | 日本大尺度吃奶做爰久久久绯色 | 狠狠干影院 | 久久精品视频一区 | 天堂一区二区三区 | 亚洲成人福利 | 欧美一级免费看 | www.久草| 国产精品久久久久永久免费看 | 欧美在线视频一区 | 草草视频在线 | 欧美黄视频 | 日韩成人高清 | 国产www视频 | 日本黄色a级片 | 欧美日韩国产在线观看 | 日韩精品免费在线观看 | 色片网址 | 欧美精品99久久久 | 久久私人影院 | aaaa级片 | 欧美精品乱码99久久蜜桃 | 美女一级片 | 成人免费激情视频 | 亚洲综合视频在线 | 亚洲香蕉视频 | 国产操操操 | 亚洲第一视频网站 | 激情视频一区 | 日韩精品视频一区二区三区 | 亚洲精品乱码久久久久久蜜桃91 | 97久久久久 | 麻豆一区二区三区 | 日本特黄特色aaa大片免费 | 欧美国产一区二区 | 日韩网站在线观看 | 国产日韩欧美亚洲 | 中文在线观看视频 |