尝试创建从code IIS应用程序获取访问被拒绝 [英] Getting access denied while trying to create iis application from code

查看:173
本文介绍了尝试创建从code IIS应用程序获取访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个从IIS网站内目录的应用程序。基本上我试图做的是重现code这种流动:一个IIS网站中的文件夹上单击鼠标右键,然后单击转换为应用程序

这是我的code:

 的DirectoryEntry appsRoot =新的DirectoryEntry(IIS://本地主机/ SVC / 3 /根);        //创建和设置新的虚拟目录
        的DirectoryEntry virtualDirectory = appsRoot.Children.Add(tool.Id.ToString(),IIsWebVirtualDir);        virtualDirectory.Properties [路径] [0] = Path.Combine(AppConfig.ToolsFilePath,tool.Id.ToString());
        virtualDirectory.Properties [AppFriendlyName] [0] = tool.Name;
        virtualDirectory.CommitChanges();        // IIS6 - 它会创建一个虚拟目录
        // IIS7 - 它会创建一个应用程序
        virtualDirectory.Invoke(AppCreate,1);

我得到的错误是访问被拒绝。

 从HRESULT异常:0X80070005(E_ACCESSDENIED))。


解决方案

您可以设置你的应用程序作为一个更加优越的用户运行,也可以提供所有必要的权限到任何用户的应用程序正在运行的。我建议后者。如果你不知道该怎么做,让我知道,我可以添加细节。

I'm trying to create a application from a directory inside a IIS website. 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.

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.

这篇关于尝试创建从code IIS应用程序获取访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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