Set Windows authentication credentials to web site to create directories

607 views Asked by At

So, I have two applications, one is Web and the other is a console app. The console app creates directories/folders and pdfs in a remote server. The web site (that is running in IIS) has a .aspx document that starts that console app. Running the console app does't give me problems, the problems come when I run the web site and fails to create the directories and pdfs. This is the error:

Error: Access to the path '\\SERVERIP\rae\RAE\' is denied.

That server has credentials and I am thinking that when I run just the console app it takes the credentials before typed (because to access the remote server I needed to type the credentials to see the folders in that server) but when I run the web site, the credentials are asked again (no prompt shown) and that's why the access is denied.

I am using C#'s System.IO.Directory.Exists(route); to check if exists and if it doesn't System.IO.Directory.CreateDirectory(route);

Is there a way to set the credentials for that server in code, on IIS or with another method?

2

There are 2 answers

0
mokh223 On

you can set the condition on web.config for specific folder only.

<configuration>
   <location path="Path/To/Public/Folder">
      <system.web>         
         <authentication mode="Windows" />
         <authorization>
            <allow users="*"/>
            <deny users="?"/>
         </authorization>
      </system.web>
   </location>
</configuration>
0
Simon On

Via the graphical interface of the IIS,

  1. Application Pools
  2. Select the one used by your application
  3. Go to advanced settings (on the far right)
  4. Set the identity to the User you want

enter image description here