2017-03-13 186 views
0

我已經繼承了MVC4應用程序。它看起來像使用Windows身份驗證,但我也被告知「Active Directory身份驗證」用於某些權限。我在web.config中看不到有關Active Directory的任何內容。 在web.config中:是否使用Active Directory身份驗證?

<authentication mode="Windows" /> 
    <roleManager defaultProvider="DefaultRoleProvider"> 
     <providers> 
     <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=21bf1234ad634e53" connectionStringName="DefaultConnection" applicationName="/" /> 
     </providers> 
    </roleManager> 

在控制器:

[Authorize(Roles = @"ABCD\EFG"), HandleError(ExceptionType = typeof(UnauthorizedAccessException), View = "UnauthorizedUser", Order = 1)] 
public class HomeController : Controller 
{ ............. 

} 

public ActionResult MyAction() 
{ 

    if (!User.IsInRole(@"ABCD\EFG")) 
    { 
     // some code 
    } 

    //............. 

} 

在此應用中使用的 「Active Directory驗證」?

謝謝

回答

0

的Windows身份驗證確實將與Active Directory只要集成的應用程序服務器是用戶在註冊了域名。

在你的配置文件中的以下行啓用這些功能。

<authentication mode="Windows" /> 

這篇文章可以幫助你進一步得到: Configure ASP.NET MVC for authentication against AD

+0

謝謝StfBln,我看到後你推薦的,有什麼讓我感到困惑的是,「匿名身份驗證」在我的情況與WA一起啓用,並沒有使用'..deny ..'語句。看來使用WA可能比那篇文章簡單得多? –

+0

我的意思是WA和AD –

相關問題