简体   繁体   English

在webservice上拒绝访问

[英]Access denied at webservice

I have a winforms, and it connecting wit webservice. 我有一个winforms,它连接机智webservice。

Webservice has method which create folder Webservice具有创建文件夹的方法

Directory.Create(path);

Webservice is at company server, and this folder must me create at another disc in out company. Webservice在公司服务器上,我必须在公司的另一张光盘上创建此文件夹。

When I invoke this method, i get exception "Access denied to path..." 当我调用此方法时,我得到异常"Access denied to path..."

When webservice was running at my computer everything was ok. 当webservice在我的电脑上运行时一切正常。

I have full access to this network disc. 我可以完全访问此网络光盘。

But how to set full access to my company server?? 但是如何设置对我公司服务器的完全访问权限?

When I check this method: 当我检查这个方法时:

[WebMethod]
        public string GetNameOfUser()
        {
            return WindowsIdentity.GetCurrent().Name;
        }

I get <string>NT AUTHORITY\\NETWORK SERVICE</string> 我得到<string>NT AUTHORITY\\NETWORK SERVICE</string>

Rest of webmethods without directory instructions working properly 其余的webmethods没有目录说明正常工作

Edited Structure 编辑结构

Computer A is in domain and there is running win forms 计算机A在域中,并且有正在运行的win表单

Server A : there is running webservice 服务器A:有运行的webservice

Network disc: there are folders with important files for winforms application 网络光盘:有一些文件夹包含winforms应用程序的重要文件

yes, we have a domain.Computer A has access to network disc. 是的,我们有一个域。计算机A可以访问网络光盘。

As I understand, your application tries to create a folder which resides on a different server than the web application. 据我所知,您的应用程序尝试创建一个文件夹,该文件夹驻留在与Web应用程序不同的服务器上。

Your web application is running under a local account NT AUTHORITY\\NETWORK SERVICE . 您的Web应用程序在本地帐户NT AUTHORITY\\NETWORK SERVICE下运行。 In order to access a network share you need it to be running under an account available on both machines, for example a domain account. 要访问网络共享,您需要在两台计算机上可用的帐户下运行,例如域帐户。

If both the web server and the server with the network share are on a domain, you can: 如果Web服务器和具有网络共享的服务器都在域上,您可以:

  1. Create a domain account 创建域帐户
  2. Grant the account write access to the parent folder where you want to create new folders 授予您要在其中创建新文件夹的父文件夹的帐户写入权限
  3. Make the Application Pool on your web server run under the domain account 使您的Web服务器上的应用程序池在域帐户下运行

This will should let your web application create foldera on the other server. 这将使您的Web应用程序在另一台服务器上创建foldera。

When you were running your web-app on your own machine, it worked onder your own account, therefore it could create directories. 当您在自己的计算机上运行Web应用程序时,它可以在您自己的帐户上运行,因此可以创建目录。

On the server the app runs under an account with very low rights. 在服务器上,应用程序在权限非常低的帐户下运行。 If you want to create those new directories below a specific fixed directory, you can allow that server account to modify that particular directory. 如果要在特定的固定目录下创建这些新目录,可以允许该服务器帐户修改该特定目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM