1

Question: I have a web setup project.

It installs the webapp and puts it into the appropriate virtual directory.
So far so good.
My question now is: how do I set folder write permission?
My problem is, I can set the permissions programmatically, but I need to know the IIS user the application runs under, since it's that user that need the permissions.

How can I get (or set) the IIS user ?

Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
  • Security tab in IIS - if you have anonymous access enabled. Whatever user if you use impersonation. You can use `HttpContext.Current.User` to check what user is authenticated. – Jaroslav Jandek Jul 12 '10 at 08:20
  • Yes, but I need to check it in the deployment project, not in the ASP.NET web application... permissions would be pretty pointless if you could give yourself those you don't have... – Stefan Steiger Jul 12 '10 at 15:25

1 Answers1

0

The default value is usually IUSR_%machinename%

You could attempt to read the IIS metabase file but it's usually in a system folder (C:\WINDOWS\system32\inetsrv\metabase.xml). Find the <IIsWebService> element with the proper Location attribute and then read the value of the AnonymousUserName attribute. I don't recommend writing directly to the metabase.

I am only familiar with IIS6 so the above may vary by version.

Hugh Jeffner
  • 2,936
  • 4
  • 32
  • 31