views:

172

answers:

2

Hi,

I have a winforms, and it connecting wit webservice.

Webservice has method which create folder

Directory.Create(path);

Webservice is at company server, and this folder must me create at another disc in out company.

When I invoke this method, i get exception "Access denied to path..."

When webservice was running at my computer everything was ok.

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>

Rest of webmethods without directory instructions working properly

Edited Structure

Computer A is in domain and there is running win forms

Server A : there is running webservice

Network disc: there are folders with important files for winforms application

yes, we have a domain.Computer A has access to network disc.

+2  A: 

As I understand, your application tries to create a folder which resides on a different server than the web application.

Your web application is running under a local account 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:

  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

This will should let your web application create foldera on the other server.

Mikael Svenson
Could you give any tips how to deal with point 3 ?? I have no idea
It's a setting on IIS. If you are using IIS6 check out http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/f05a7c2b-36b0-4b6e-ac7c-662700081f25.mspx?mfr=true. For IIS7 check out http://technet.microsoft.com/en-us/library/cc771170(WS.10).aspx
Mikael Svenson
A: 

When you were running your web-app on your own machine, it worked onder your own account, therefore it could create directories.

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.

Hans Kesting