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

如何使用 C# 按用戶名搜索 Active Directory?

How can I search Active Directory by username using C#?(如何使用 C# 按用戶名搜索 Active Directory?)
本文介紹了如何使用 C# 按用戶名搜索 Active Directory?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在嘗試通過(guò)用戶名admin"搜索活動(dòng)目錄.我知道目錄中存在具有該用戶名的用戶,但搜索一直沒(méi)有結(jié)果.

I'm trying to search active directory by the username 'admin'. I know for a fact that there is a user with that username in the directory, but the search keeps coming back with nothing.

var attributeName = "userPrincipalName";
var searchString = "admin"
var ent = new DirectoryEntry("LDAP://"dc=corp,dc=contoso,dc=com")
var mySearcher = new DirectorySearcher(ent);
mySearcher.Filter = string.Format("(&(objectClass=user)({0}={1}))", attributeName, searchString);

var userResult = mySearcher.FindOne();

userResult 總是以 null 結(jié)束.我很想知道為什么,一定有我遺漏的東西.

userResult always ends up null. I would love to know why, there must be something that I'm missing.

推薦答案

原來(lái)userPrincipalName"需要全部小寫(xiě)(userprincipalname").很高興知道,感謝您的回復(fù).

It turns out that "userPrincipalName" needed to be all lower-case ("userprincipalname"). Good to know, thanks for your responses.

這篇關(guān)于如何使用 C# 按用戶名搜索 Active Directory?的文章就介紹到這了,希望我們推薦的答案對(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# 中使用可空類(lèi)型)
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)用)
主站蜘蛛池模板: 亚洲精品一区中文字幕乱码 | 亚洲一区中文 | 完全免费在线视频 | 男女网站视频 | 中文字幕一区二区三区四区 | 亚洲精品久久久久久久久久久 | 天天草视频 | 成人影院一区二区三区 | 亚洲成人a v | 久久99精品久久久久婷婷 | 97超碰人人 | 欧洲毛片 | 国产精品三级 | 精精国产xxxx视频在线播放 | 亚洲国产精品一区二区第一页 | 欧美影院 | 久久亚洲免费 | 97精品国产一区二区三区 | 国产成人精品一区 | 在线免费观看毛片 | 99精品视频在线 | 久久伊人一区 | 亚洲欧美日韩在线不卡 | 国产日日操 | 国产成人综合一区二区三区 | 在线观看亚洲专区 | 日韩av在线一区 | 97精品一区二区 | 日日夜夜精品视频 | 超碰操 | 日韩一区二区在线免费观看 | 福利国产 | 亚洲综合二区 | 蜜桃一区| 中文字幕第一页在线 | 午夜免费网站 | 国产午夜av片 | 成人福利电影 | 一区二区三区免费 | 国产精品一区一区 | 999久久久久久久久6666 |