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

使用 C# 從 ASP.Net MVC 訪問 Active Directory

Accessing Active Directory from ASP.Net MVC using C#(使用 C# 從 ASP.Net MVC 訪問 Active Directory)
本文介紹了使用 C# 從 ASP.Net MVC 訪問 Active Directory的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我需要訪問 Active Directory 以獲取有關客戶所屬組的信息.我的項目是一個使用 C# 的 ASP.Net MVC 應用程序.我以前從未針對 Active Directory 進行過編程,因此需要一些關于最佳入門方法、用于訪問信息的安全模型的建議,并且可能會為我提供一些不錯的教程.

I need to access Active Directory to get information about groups that customers belong to. The project I have is an ASP.Net MVC application using C#. I've never programmed against Active Directory before, and need some advice on what the best way to get started is, what security model to use to access the information, and maybe point me to some good tutorials.

推薦答案

由于您使用的是 MVC,您可以訪問新的 System.DirectoryServices.AccountManagement .NET 3.5 中的命名空間.這些類應該優(yōu)先于 DirectoryServices 本身中的舊類,因為它們使用起來要簡單得多.有幾個問題在 3.5 中尚未解決(例如,查詢組時限制 1500 個成員),但我確信這些問題已在 .NET 4.0 中得到修復.對于大多數(shù)任務,新類都能很好地工作.

Since you're using MVC, you have access to the new System.DirectoryServices.AccountManagement namespace in .NET 3.5. These classes should be preferred over the older classes in DirectoryServices itself as they are much simpler to use. There are a couple of gotchas that haven't been solved in 3.5 (1500 member limit when querying groups, for instance), but I'm assured that these have been fixed in .NET 4.0. For most tasks, the new classes work very well.

 using (var context = new PrincipalContext( ContextType.Domain )) 
 {
      using (var user = UserPrincipal.FindByIdentity( context, "username" ))
      {
          var groups = user.GetAuthorizationGroups();
          ...
      }
 }

這篇關于使用 C# 從 ASP.Net MVC 訪問 Active Directory的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關文檔推薦

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 的方法調(diào)用)
主站蜘蛛池模板: 国产激情一区二区三区 | 日韩精品久久 | 亚洲在线播放 | 国语av| 亚洲欧美日韩另类 | 国产在线免费 | 91美女视频| 国内福利视频 | 婷婷视频网| 老司机午夜免费精品视频 | 操操影院| 久久天堂网 | 成人在线a | 色婷婷香蕉在线一区二区 | av免费看片| 99午夜| 欧美视频一二三区 | 国产免费一区二区三区在线观看 | 欧美日韩一区在线 | 国产一区在线看 | 久久久久久国产精品 | 一区二区三区影院 | 亚洲视频精品 | 亚欧在线观看 | 日韩黄色大片 | 国产伦精品一区二区三区免费视频 | 在线播放亚洲 | 国产精品成人一区二区三区 | 密乳av| 免费久久久 | 免费黄色一级 | 欧美日韩在线一区 | 91爱视频| 日本不卡视频 | 欧美大片18| 国产亚洲久一区二区 | 欧美一级特黄aa大片 | 久久久久精 | 99re在线观看视频 | 免费久久| 日韩精品一级 |