Link to home
Start Free TrialLog in
Avatar of secuteamers
secuteamersFlag for Belgium

asked on

Create Word file (serverside) as internet-user

I have an online application that creates and saves Word documents server-side. I didn't work until i gave admin-rights to the iis-user or internetuser. I know it's unsafe to do such thing. Does anyone know which specific rights i have to gave to the internetuser in order to let the app work?
Avatar of Irwin Santos
Irwin Santos
Flag of United States of America image

at least read with script & execute

if they will be saving data, then you have to add modify/write.
Avatar of secuteamers

ASKER

yeah, but which process?
what's the application?
A C# (asp.net) application that opens Word, Creates a document and saves it (all serverside)
you need to grant access to execute that ASP.NET file (if you haven't already).

the next thing is to have NTFS permission setup to READ/MODIFY/WRITE on the folder that will host the saved files

AND

go into IIS and make sure that you have setup authentication for that access to the folder.
it already has both. It still must be something else.

When i compile my site it creates the following url:
http://localhost:3341/frontend/view.aspx
All functions work in this case

But when i surf to http://localhost/frontend/view.aspx (as on a regular webserver) it does work, but only until i get to the function that adds a doc to the Word-file.
Permit asp.net to Read/Write/Modify the location where the document will be stored on your webserver


how can i permit asp.net to do this? This is not a defined user or group. I have permitted the internetguestaccount to do this, but no success.
list the permissions that you have for admin AND the guest user
can i find these permissions in the Computer Management?
I have following user-accounts:
- Administrator
- ASPNET
- Guest (disabled)
- IUSR_MACHINE
- IWAM_MACHINE

What do i do next?
I guess i'm almost at the solution?
NTFS permissions on the folder need to be set.  I'm not sure how you're authenticating but the account that you are using must have
READ/MODIFY/WRITE

on the folder... go to MY COMPUTER, right click on the folder you want to save your Word Document to, then select the user & permissions

Within IIS, you will pretty much do the same thing.... locate the folder in your website, right click and choose the account.. apply the same permissions.
ASKER CERTIFIED SOLUTION
Avatar of Sammy
Sammy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i have given fullcontrol to the aspnet user to the whole project folder and done the same in IIS, but still no solution.
I've added the aspnet user to the administrator group, and with success, but i can keep this situation because of the security leak, right.

Any suggestions?
by the way: the error that i'm getting is:

"Insufficient memory. Save the document now." -> freely translated from my own language. (Dutch)
put this in your code as your 1st & 2nd lines in your .asp file
<% @ LANGUAGE = VBSCRIPT%>
<% Option Explicit %>

go into IE- TOOLS-INTERNET OPTIONS, ADVANCE tab, then locate and UNCHECK "SHOW FRIENDLY HTTP ERROR MESSAGES"

Run the code

post back the exact error please
it's a c# file. So why use vbscript?
this is my error page:

"Er is onvoldoende geheugen. Sla het document nu op. " (meaning: Insufficient memory. Save the document now"

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Er is onvoldoende geheugen. Sla het document nu op.

Source Error:


Line 49:         //oWord.Activate();
Line 50:
Line 51:         oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
Line 52:         //oDoc.Activate();
Line 53:
 

Source File: c:\Inetpub\wwwroot\btech\questionnaire\App_Code\open_word.cs    Line: 51

Stack Trace:


[COMException (0x800a13e9): Er is onvoldoende geheugen. Sla het document nu op.]
   Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible) +0
   open_word.start_doc(ArrayList prodarray, String filepath, String mylang) in c:\Inetpub\wwwroot\btech\questionnaire\App_Code\open_word.cs:51
   _Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\btech\questionnaire\view.aspx.cs:303
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

 
Unfortunately I cant read nor speak Dutch, specially at this time of day :-)
If you take a look here you will see a complete working example on how to open, save and create word documents and templates
http://www.codeproject.com/aspnet/wordapplication.asp

just dont forget to call  System.GC.Collect() after you release your memory to avoid memory leak.

HTH
"it's a c# file. So why use vbscript?"....sorry missed your earlier comment mentioning c#