Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.. :)
Posted
Comments
Aydin Homay 11-May-15 10:18am    
Do you want something like installation batch file to installing your service and setting up your installed service permissions such as user and etc. ?

1 solution

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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900