ऐसा लगता है आपकी साइट के लिए इंटरनेट सूचना प्रणाली विन्यास को बदलने के लिए उम्मीद कर रहा है; अगर वह यह है कि इस तरह से सही कुछ काम करना चाहिए:
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();
}
ऊपर कोड आप अधिकरण नियम किसी विशेष साइट तक पहुँचने के लिए एक समूह में किसी विशेष उपयोगकर्ता की अनुमति देता है कि बनाने के लिए अनुमति देगा। इस मामले में साइट Contoso है।
तो इस साइट के लिए बेनामी प्रमाणीकरण अक्षम हो जाएगा; तो साइट के लिए बेसिक & विंडोज प्रमाणीकरण सक्षम:
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();
}
या यदि आप चाहें तो आप बस एक आईआईएस प्रबंधक उपयोगकर्ता खाता जोड़ सकते हैं; जिसे आप उन अन्य अनुप्रयोगों में हेरफेर और प्रबंधित करने के लिए कुछ अनुमतियों पर सेट कर सकते हैं।
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"] = @"[email protected]";
addElement["enabled"] = true;
credentialsCollection.Add(addElement);
serverManager.CommitChanges();
}
इंटरनेट सूचना प्रणाली के भीतर बहुत लचीलापन है; यह काफी शक्तिशाली है। संदर्भ के माध्यम से दस्तावेज भी गहराई में है। उदाहरण काफी अपने विशेष उपयोग करने के लिए अनुकूलित किया जा करने के लिए या कम से कम यह है कि तुम क्या चाहते हो बनाने के लिए समझ का एक स्तर प्रदान अयोग्य हैं।
उम्मीद है कि मदद, उन उदाहरणों से here: