如何以编程方式在IIS中设置网站或REST服务的权限 [英] How to programmatically set permission to Website or REST Service in IIS

查看:85
本文介绍了如何以编程方式在IIS中设置网站或REST服务的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



可以指导我如何使用C#以编程方式在IIS中设置网站或REST服务的权限。



背景:

我有一个用C#4.0构建的自定义服务器安装程序。

使用这个我在IIS中安装一个REST服务Microsoft.Web.Administration dll的帮助。

成功安装后服务正常。



问题:

REST服务的实现是使用NLog以.txt文件的形式捕获错误。

当我从安装程序安装服务时,日志文件没有生成(而它在手动安装时工作)



如果我手动从IIS为IIS_IUSRS编辑权限并为用户设置完全控制,然后它工作正常。



可以告诉我如何在安装服务时以编程方式实现相同的操作



在此先感谢.. :)

Hi All,

Can any guide me about how to programmatically set permission to Website or REST Service in IIS from C#.

BACKGROUND:
I have a custom Server Installer Program build in C# 4.0.
Using this I am installing a REST service in IIS with the help of Microsoft.Web.Administration dll.
The service works fine after the successful installation.

ISSUE:
The implementation of REST service is using NLog to catching errors in the form of .txt file.
When I install the service from my Installer, The log file is not generating (Whereas it work on manual installation)

If I manually edit permission from IIS for IIS_IUSRS and set full control for the user, then it works fine.

Can any tell me how to achieve the same programmatically while installing the service

Thanks in advance.. :)

推荐答案

首先,我不建议使用IIS_IUSRS帐户为了这。我强烈建议您创建一个服务帐户来运行您的应用程序。请看一下:指定应用程序池的标识(IIS 7 ) [ ^ ]



其次,对于您的部署,我建议编写PowerShell脚本。此脚本将创建应用程序池,设置池的标识,在IIS中创建网站或目录,并使用适当的权限为网站创建物理文件夹。此链接将为您提供更多指导: PowerShell管理单元:创建网站,Web应用程序,虚拟目录和应用程序池 [ ^ ]



我希望这有帮助!
First, I don't recommend using the IIS_IUSRS account for this. I strongly recommend creating a service account to run your application under. Take a look at this: Specify an Identity for an Application Pool (IIS 7)[^]

Second, for your deployment, I suggest writing a PowerShell script. This script would create your Application Pool, set the identity of the pool, create the website or directory in IIS, and create the physical folder for the web site with appropriate permissions. This link will give you more guidance on doing it: PowerShell Snap-in: Creating Web-Sites, Web applications, Virtual Directories and Application Pools [^]

I hope this helps!


这篇关于如何以编程方式在IIS中设置网站或REST服务的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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