Impersonate 的應用在windows/Forms不同驗證類型下的表現!

來源:互聯網
上載者:User

首先,我在頁面中寫於下列代碼來輸出3種不同的Credential。

 Response.Write("Thread: " + Thread.CurrentPrincipal.Identity.Name+"<br/>");
        Response.Write("Windws Identity: " + WindowsIdentity.GetCurrent().Name + "<br/>");
        Response.Write("HttpContext: " + User.Identity.Name + "<br/>");

Thread:是輸出託管線程的identity。

Window Identity:輸出OS 的identity.一般是NT AUTHORITY\NETWORK SERVICE,因為.NET Framework寄宿在w3wp.exe(IIS>6.0)。

HttpContext:標識當前上下文Credential.

如果你用的是Windows驗證,則Thread,HttpContext為空白,但windows Identity為:NT AUTHORITY\NETWORK SERVICE.

所以此時,如果你將Impersonate='True',那麼windows Identity: NT AUTHORITY\IUSR
因為Impersonate類比的window賬戶.

當你用的是Forms驗證,則登入以後:

Thread: gary
Windws Identity: NT AUTHORITY\NETWORK SERVICE
HttpContext: gary
所以我們看到,Thread,HttpContext是在託管環境中設定的. 順便說一句,當你啟用windows 驗證,而你想設定Forms驗證一樣啟用了Authority.

   <authorization>
      <allow roles="Role1"/>
      <deny users="*"/>
     </authorization>

那麼總是會返回401 unauthority錯誤。因為不是Adminstrate 組

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.