IIS 5 和 IIS 6 的安全性差異

來源:互聯網
上載者:User
代碼如下:using System;
using System.DirectoryServices;

class TestIIS
{
    public static void Main()
    {            
        string comment,bindings;
        DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/w3svc");
        
         foreach(DirectoryEntry dir in entry.Children)
         {
               if(dir.SchemaClassName == "IIsWebServer")
               {
                   comment  = dir.Properties["ServerComment"].Value.ToString();
                   bindings = dir.Properties["ServerBindings"].Value.ToString();         
                   if (bindings == ":80:")
                   {
                       Console.WriteLine(dir.Properties["MaxConnections"].Value);
                   }
               }
        }
       }
}

以上代碼,在控制台下面是可以直接啟動並執行.
如果將上面的代碼稍稍修改(將Console.WriteLine改為Response.Write),封裝成方法,放到一個aspx頁面裡面,拿到IIS上啟動並執行話,會發現比較有趣的現象:
在IIS6上正常運行,在IIS 5上卻會拋出拒絕存取的安全性異常.
如果你想讓上述代碼在IIS 5 和 6 上面都運行正常的話,需要做以下操作:
1.首先通過.NET FX 1.1 的組態工具將你的程式集配置為FullTrust
可以參考下面的連結:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/entsecpoladmin.asp
2.將你的IIS的匿名帳號配置到Administrator 群組裡面,或者修改web.config檔案
也可以參考下面的連結:
http://support.microsoft.com/default.aspx?scid=kb;en-us;306158
雖然可以解決問題,但是我的疑惑是:
IIS 6 的安全性應該比IIS 5 更全面,為什麼在 IIS 6 上卻正常?
上述的代碼都是訪問,並非修改設定, IIS 5 的安全要求就這麼苛刻?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.