久久久久久久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()無效?)
主站蜘蛛池模板: 成人做爰69片免费观看 | 国产第一页在线播放 | 亚洲第一av | 久久精品免费看 | 国产你懂的在线观看 | 久久成人免费视频 | 日韩黄色小视频 | 欧美多人在线 | 岛国视频| 中文字幕精品视频 | 在线一区二区国产 | 二区国产 | av黄色免费在线观看 | 99re超碰 | 91精品一区二区三区久久久久 | 亚洲 中文 欧美 日韩 在线观看 | 天天射色综合 | 91视视频在线观看入口直接观看 | 精品国产乱码久久久久久图片 | 免费久久99精品国产婷婷六月 | 国产成人jvid在线播放 | a级毛片毛片免费观看久潮喷 | 成人免费观看视频 | 一级在线观看 | 久久久妇女国产精品影视 | 男女羞羞视频网站 | 欧美午夜一区 | 亚洲一区二区在线免费观看 | 狠狠色综合网站久久久久久久 | 天天精品在线 | 大香网伊人 | 阿v视频在线观看 | 日本大香伊一区二区三区 | 一级免费看片 | 久久天堂 | 一区二区三区国产 | 国产精品久久久久久久久久免费看 | 9999国产精品欧美久久久久久 | 在线成人av | 国产在线精品一区二区三区 | 国产一级片网站 |