久久久久久久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 的方法調用)
主站蜘蛛池模板: 在线小视频 | 中文字幕成人 | 视频在线一区二区 | 特级黄一级播放 | 午夜影院| 亚洲在线一区二区 | 精品欧美一区二区精品久久久 | 亚洲欧美视频一区 | 亚洲高清视频一区二区 | 狠狠入ady亚洲精品经典电影 | 在线欧美视频 | 性色综合| 精品久久久久久亚洲综合网 | 国产在线精品一区 | 亚洲 中文 欧美 日韩 在线观看 | 特黄视频| 亚洲乱码一区二区三区在线观看 | 欧美精品乱码99久久影院 | 免费黄色特级片 | 国产精品揄拍一区二区 | 欧美激情一区二区三区 | 一区二区三区免费 | 91精品国模一区二区三区 | 一级黄色毛片 | 日本在线视频一区二区 | 亚洲欧美日韩精品久久亚洲区 | 国产视频在线观看一区二区三区 | 欧美美女二区 | 免费视频中文字幕 | 成人小视频在线观看 | 老外几下就让我高潮了 | 精品久久久久久久久久久久 | 久久av网站 | 欧日韩在线| 亚洲视频三区 | 国产精品夜夜夜一区二区三区尤 | 亚洲一区二区在线视频 | 亚洲视频精品 | 婷婷久久综合 | 国产91在线精品 | 久草福利 |