无法以编程方式向 IIS 添加绑定 - redirection.config 权限(带视频!) [英] Cant add bindings to IIS programmatically - redirection.config permissions (with a video!)

查看:15
本文介绍了无法以编程方式向 IIS 添加绑定 - redirection.config 权限(带视频!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题的视频摘要

但是还是不行.

答案

网站不在 IIS 组下运行.谁拥有应用程序池就是用户,这就是需要权限的用户.或者将该用户放在 IIS_IUSRS 组中.

解决方案

找出您的应用程序池正在运行的帐户.然后,您需要授予该帐户访问整个 %SystemRoot%System32inetsrvconfig 文件夹的权限.我只允许访问 %SystemRoot%System32inetsrvconfig edirection.config

是不够的

Here is a video summary of my problem http://screencast.com/t/v6th4BuRLhV

I am trying to add bindings programmatically to IIS with this code:

public void AddBindings(string sitename, string hostname)
{
  ServerManager serverMgr = new ServerManager();

  Site mySite = serverMgr.Sites[sitename];

  mySite.Bindings.Add("*:80:" + hostname, "http");
  mySite.ServerAutoStart = true;

  serverMgr.CommitChanges();
}

And I get this error:

Filename: redirection.config
Error: Cannot read configuration file due to insufficient permissions

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Filename: redirection.config
Error: Cannot read configuration file due to insufficient permissions


ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

I have addressed the permissions on redirection.config (both IUSR and IIS_IUSRS have permissions)

As well as the errors on web.config as suggested here http://www.codeproject.com/Questions/348972/Error-Cannot-read-configuration-file-due-to-insuff

But it still doesn't work.

ANSWER

Websites don't run under the IIS group. Whoever owns the app pool is the user and this is the user that needs permission. Or put that user in the IIS_IUSRS group.

解决方案

Figure out what account your application pool is running as. Then you need to give that account access to the entire %SystemRoot%System32inetsrvconfig folder. It wasn't enough for me to give access to just %SystemRoot%System32inetsrvconfig edirection.config

这篇关于无法以编程方式向 IIS 添加绑定 - redirection.config 权限(带视频!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆