简体   繁体   English

尝试从代码创建iis应用程序时拒绝访问

[英]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.

相关问题 从代码创建IIS应用程序 - Create IIS Application from Code 尝试使用 INamedBucketProvider 从 C# 应用程序连接到 Couchbase 时访问被拒绝错误 - Access Denied error while trying to use INamedBucketProvider to connect on Couchbase from C# application 尝试在Silverlight中打开套接字时获取访问被拒绝异常 - Getting Access Denied Exception while trying to Open Socket In Silverlight 尝试将文件写入某个位置时拒绝访问 - Access denied while trying to write file to a location 尝试运行项目时出错:访问被拒绝 - Error while trying to run project: Access is denied 尝试使用asp.net Web应用程序提取系统信息时拒绝访问 - Getting access denied when trying to extract system information using a asp.net web application 尝试连接到远程IIS服务器时出现“访问被拒绝”-C# - “Access Denied” when trying to connect to remote IIS server - C# 尝试生成报告时,IIS 7对路径的访问被拒绝 - IIS 7 Access to the path is denied when trying to generate report 尝试访问 IIS 时出现 RPC 错误 - RPC Error while trying to access IIS 尝试访问IIS中托管的应用程序时出现“无法找到资源”错误 - getting “The resource cannot be found” error when trying to access application hosted in IIS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM