[英]Getting access denied while trying to create iis application from code
I'm trying to create a application from a directory inside a IIS website. 我正在尝试从IIS网站内的目录创建应用程序。 Basically what I'm trying to do is to reproduce this flow in code: right-click on a folder inside an IIS website and click to convert to application.
基本上,我想做的是用代码重现此流程:右键单击IIS网站内的文件夹,然后单击以转换为应用程序。
this is my code: 这是我的代码:
DirectoryEntry appsRoot = new DirectoryEntry("IIS://localhost/w3svc/3/Root");
//Create and setup new virtual directory
DirectoryEntry virtualDirectory = appsRoot.Children.Add(tool.Id.ToString(), "IIsWebVirtualDir");
virtualDirectory.Properties["Path"][0] = Path.Combine(AppConfig.ToolsFilePath, tool.Id.ToString());
virtualDirectory.Properties["AppFriendlyName"][0] = tool.Name;
virtualDirectory.CommitChanges();
// IIS6 - it will create a virtual directory
// IIS7 - it will create an application
virtualDirectory.Invoke("AppCreate", 1);
The error I get is Access is denied. 我得到的错误是访问被拒绝。
Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
You can either set up your application to run as a more privileged user, or you can give all of the necessary permissions to whatever user the application is currently running as. 您可以将应用程序设置为以特权更高的用户身份运行,或者可以将所有必要的权限授予该应用程序当前以其身份运行的任何用户。 I'd suggest the latter.
我建议后者。 If you don't know how to do that let me know and I can add details.
如果您不知道该怎么做,请告诉我,我可以添加详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.