久久久久久久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的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

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

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īng)該優(yōu)先于 DirectoryServices 本身中的舊類,因?yàn)樗鼈兪褂闷饋硪唵蔚枚?有幾個(gè)問題在 3.5 中尚未解決(例如,查詢組時(shí)限制 1500 個(gè)成員),但我確信這些問題已在 .NET 4.0 中得到修復(fù).對(duì)于大多數(shù)任務(wù),新類都能很好地工作.

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();
          ...
      }
 }

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

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

相關(guān)文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應(yīng)該總是在 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#中將空值設(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)用)
主站蜘蛛池模板: 夜夜精品浪潮av一区二区三区 | av天天澡天天爽天天av | 精品久久久久久中文字幕 | 99免费精品| 欧美精品一区二区三区在线播放 | 97碰碰碰| 91视频在线看 | 国产一区二区 | 四虎影院在线免费观看 | 天天射夜夜操 | 丁香婷婷久久久综合精品国产 | 国产日韩视频 | 午夜日韩视频 | 国产国拍亚洲精品av | 久久久精品视 | 亚洲 欧美 综合 | 久久久久久91香蕉国产 | 日韩精品一区二区三区中文在线 | 国产精品99999 | 欧美日韩亚洲国产 | 日本不卡免费新一二三区 | 成人午夜在线视频 | 国产综合久久久 | 亚洲一二三在线 | 特黄一级 | 国产精品乱码一二三区的特点 | av毛片| 国产亚洲精品久久情网 | 午夜精品一区二区三区在线视频 | 久久成人精品视频 | 日韩视频 中文字幕 | 久久国产精品一区二区 | 玖玖国产| 亚洲激情在线 | 在线免费观看日本 | 成人高清在线视频 | 久久ww| 国产精品视频久久久久 | 91精品国产综合久久精品图片 | 91精品国产色综合久久不卡蜜臀 | 亚洲精品欧美一区二区三区 |