0

I'm trying to write a file to another machine (not on the same domain), using a share that is available on that machine. I saw this question, using StreamWriter on server in C# , and I guess the person who asked the question got the answer, but I'm not use exactly how to do this. THe MSDN article it points to requires you to make a whole class to support an impersonation - is there no easier way to do this? Can I make a user on my machine that can do something like that? Can I set up my asp.net user to impersonate, or run IIS using a different user?

Community
  • 1
  • 1
M.R.
  • 4,737
  • 3
  • 37
  • 81

2 Answers2

1

I think you can use impersonation. Add next code to your web.config

<system.web>
    <identity impersonate="true" userName="MyUser" password="MyPassword"/>
</system.web>
Sanja Melnichuk
  • 3,465
  • 3
  • 25
  • 46
1

You can create a mapped drive to the network share on your web server or you can setup impersonation in web.config. See here.

But I suggest you follow the code to impersonate a specific user because it's a better practice.

Since the resource is not on the same domain as your web server, you'll need to setup trust between the domains. Here's a start.

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137