2

빈 Windows 인증 및 ID와 속성에 권한을 부여 웹 설정에서사용자 정의 I는 권한 부여 속성의 구현을 만들

[CustomAuthorize] 
public class AccountController : Controller 
{ 
    /// <summary> 
    /// Log4net logger 
    /// </summary> 
    private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 

    /// <summary> 
    /// Index method run on start of the Account view. 
    /// </summary> 
    /// <returns>Action Result.</returns> 
    [CustomAuthorize] 
    public ActionResult Index() 
    { 
     WindowsIdentity identity = System.Web.HttpContext.Current.Request.LogonUserIdentity; 
     logger.Info("User name IsAuthenticated " + identity.IsAuthenticated); 
     logger.Info("User name " + identity.Name); 
     if (identity != null) 
     { 
      LdapService ldap = new LdapService(); 
      string[] domainUser = identity.Name.Split('\\'); 
      if (domainUser[1].Equals(AccessHelper.ReceptionUserName)) 
      { 
       return RedirectToAction("Index", "Guest"); 
      } 
      else 
       if (ldap.IsUserInReception(domainUser[1])) 
       { 
        return RedirectToAction("Index", "Reception"); 
       } 
       else 
       { 
        return RedirectToAction("Index", "Employee"); 
       } 
     } 
     return RedirectToAction("Index", "Employee"); 
    } 

나는 윈도우 인증을 설정합니다 .. . : 나는 서버 IIS 및 실행에 대한 내 Asp.net MVC 4 응용 프로그램을 배포 할 때

<appSettings> 
    <add key="webpages:Version" value="2.0.0.0" /> 
    <add key="webpages:Enabled" value="false" /> 
    <add key="PreserveLoginUrl" value="true" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    <add key="autoFormsAuthentication" value="false" /> 
    <add key="enableSimpleMembership" value="false" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    <globalization uiCulture="en-GB" culture="en-GB" /> 
    <authentication mode="Windows" /> 
    <identity impersonate="true" /> 

난 보라가 나는 인증되지 않았고 사용자는 비어 있다고 제안했다. 내 페이지가 Windows 자격 증명에 의한 인증을 받아야한다는 것을 알지 못하는 이유는 무엇입니까?

+0

Windows 기반 응용 프로그램에서 ldapservice를 사용하는 이유는 무엇입니까? –

답변

3

서버의 IIS에서 익명 인증을 사용하지 않도록 설정하십시오.