欧美成人精品手机在线观看_69视频国产_动漫精品第一页_日韩中文字幕网 - 日本欧美一区二区

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

【C#】使用ServerManager類配置IIS身份驗證設(shè)置

admin
2021年5月11日 15:46 本文熱度 4088
我正在使用ServerManager類(來自Microsoft.Web.Administration)在運(yùn)行IIS 7的服務(wù)器上創(chuàng)建應(yīng)用程序,我想配置應(yīng)用程序是否在應(yīng)用程序基礎(chǔ)上使用匿名身份驗證或 Windows身份驗證,因此我不能簡單地要求IT更改根站點(diǎn)上的設(shè)置,該應(yīng)用程序的內(nèi)容屬于第三方,因此我不允許更改應(yīng)用程序內(nèi)的web.config文件。

Application類沒有公開任何有用的屬性,但也許我可以使用ServerManager的GetApplicationHostConfiguration方法完成某些事情?

聽起來你希望改變網(wǎng)站的互聯(lián)網(wǎng)信息系統(tǒng)配置,如果這是正確的,這樣的事情應(yīng)該有效:

using (ServerManager serverManager = new ServerManager())
{
    Configuration config = serverManager.GetWebConfiguration("Contoso");
    ConfigurationSection authorizationSection = config.GetSection("system.webServer/security/authorization");
    ConfigurationElementCollection authorizationCollection = authorizationSection.GetCollection();
    ConfigurationElement addElement = authorizationCollection.CreateElement("add");
    addElement["accessType"] = @"Allow";
    addElement["roles"] = @"administrators";
    authorizationCollection.Add(addElement);
    serverManager.CommitChanges();
 }

上面的代碼允許您創(chuàng)建一個授權(quán)規(guī)則,允許組中的特定用戶訪問特定站點(diǎn)。在這種情況下,該網(wǎng)站是Contoso。

然后,這將禁用該站點(diǎn)的匿名身份驗證,然后啟用Basic&該站點(diǎn)的Windows身份驗證:

using(ServerManager serverManager = new ServerManager()) 
{ 
    Configuration config = serverManager.GetApplicationHostConfiguration();
    ConfigurationSection anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Contoso");
    anonymousAuthenticationSection["enabled"] = false;
    ConfigurationSection basicAuthenticationSection = config.GetSection("system.webServer/security/authentication/basicAuthentication", "Contoso");
    basicAuthenticationSection["enabled"] = true;
    ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "Contoso");
    windowsAuthenticationSection["enabled"] = true;
    serverManager.CommitChanges();
}

或者,您可以根據(jù)需要添加IIS管理器用戶帳戶,您可以設(shè)置為某些權(quán)限來操縱和管理其他應(yīng)用程序。

using (ServerManager serverManager = new ServerManager())
{
    Configuration config = serverManager.GetAdministrationConfiguration();
    ConfigurationSection authenticationSection = config.GetSection("system.webServer/management/authentication");
    ConfigurationElementCollection credentialsCollection = authenticationSection.GetCollection("credentials");
    ConfigurationElement addElement = credentialsCollection.CreateElement("add");
    addElement["name"] = @"ContosoUser";
    addElement["password"] = @"P@ssw0rd";
    addElement["enabled"] = true;
    credentialsCollection.Add(addElement);
    serverManager.CommitChanges();
}

互聯(lián)網(wǎng)信息系統(tǒng)具有很大的靈活性,它非常強(qiáng)大,通過那里參考的文件也非常深入。這些示例很難適應(yīng)您的特定用途,或者至少提供一定程度的理解,以使其按照您的意愿行事。

希望有幫助,這些例子來自here


該文章在 2021/5/11 15:46:34 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場、車隊、財務(wù)費(fèi)用、相關(guān)報表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉儲管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved