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

UserPrincipal 對象中的域名在哪里?

Where is the domain name in a UserPrincipal object?(UserPrincipal 對象中的域名在哪里?)
本文介紹了UserPrincipal 對象中的域名在哪里?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 System.DirectoryServices.ActiveDirectory 類來查找所有 Active Directory 用戶.代碼很簡單:

I'm using the System.DirectoryServices.ActiveDirectory classes to find all Active Directory users. The code is very simple:

var context = new PrincipalContext(ContextType.Domain);
var searcher = new PrincipalSearcher(new UserPrincipal(context));
var results = searcher.FindAll();

我想以友好"(又名Windows 2000 之前"格式)獲取域限定用戶名,例如.CONTOSOSmithJ".UserPrincipal.SamAccountName 給了我用戶名部分,但我如何獲得域部分?我不能假設域將與機器或當前用戶的域相同.

I want to get the domain-qualified username in the "friendly" (aka. "pre-Windows 2000" format), eg. "CONTOSOSmithJ". UserPrincipal.SamAccountName gives me the username part, but how do I get the domain part? I cannot assume that the domain will be the same as the machine's or current user's domain.

推薦答案

對于 AD DS,msDS-PrincipalName 的值是 NetBIOS 域名,后跟一個反斜杠(").

For AD DS, the value of msDS-PrincipalName is the NetBIOS domain name, followed by a backslash ("").

您可以使用:

/* Retreiving the root domain attributes
 */ 
sFromWhere = "LDAP://DC_DNS_NAME:389/dc=dom,dc=fr"; 
DirectoryEntry deBase = new DirectoryEntry(sFromWhere, "AdminLogin", "PWD"); 

DirectorySearcher dsLookForDomain = new DirectorySearcher(deBase); 
dsLookForDomain.Filter = "(objectClass=*)"; 
dsLookForDomain.SearchScope = SearchScope.base; 
dsLookForDomain.PropertiesToLoad.Add("msDS-PrincipalName"); 

SearchResult srcDomains = dsLookForDomain.FindOne();

這篇關于UserPrincipal 對象中的域名在哪里?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

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 中的空值?)
Asp.net System.Web.HttpContext.Current.Session null in global.asax(Asp.net System.Web.HttpContext.Current.Session 在 global.asax 中為 null)
Caught exception is null itself !(捕獲的異常本身為空!)
Why is it Valid to Concatenate Null Strings but not to Call quot;null.ToString()quot;?(為什么連接空字符串有效但調用“null.ToString()無效?)
主站蜘蛛池模板: 人操人免费视频 | 国产欧美精品区一区二区三区 | 日本黄色一级片视频 | 欧美亚洲日本 | 日日碰狠狠躁久久躁婷婷 | 91麻豆产精品久久久久久 | 91一区二区| 欧美中文字幕一区二区 | 精品一区二区在线观看 | 日韩精品免费一区二区在线观看 | 性做久久久久久免费观看欧美 | 精品96久久久久久中文字幕无 | 欧州一区二区三区 | 成人精品视频在线 | 永久免费av | 四虎影院一区二区 | jizz中国日本 | 精品一区二区久久久久久久网站 | 国产特一级黄色片 | 成人精品久久日伦片大全免费 | 97av在线| 免费麻豆视频 | 亚洲综合在线视频 | 免费一级黄色录像 | 成年人精品视频在线观看 | 国产精品综合 | 久久久国| 日本久草| 99亚洲精品视频 | 久久精品中文字幕 | 精品一区电影 | 欧美精品电影一区 | 久久久久网站 | 国产色婷婷久久99精品91 | 91在线视频免费观看 | av黄色片在线观看 | 国产剧情一区 | 国产精品久久av | 蜜臀网 | 综合九九 | 国产精品久久久久久久粉嫩 |