Office interop from asp.net (vb) - permissions problem....

S

Stu

Hi,

I am trying to open a word document from an asp.net page but I keep getting
an access denied error when I try to create an instance of the word
applications.

I have created references to the Office 11.0 Object and it imported the
other references (except stdole which I did manually)

I have imported namepsaces:

Imports System.ComponentModel
Imports Microsoft.Office.Interop

The code I am calling is:

Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
oWordDoc = oWordApp.Documents.Open("c:\text.doc")

The error below says I should give access permission to the ASPNET user. But
a) that user does not exist on my machine - I think it is 'Authenticated
user' that I need and b) which file needs to be given permission?!? I have
tried giving this user full control over the entire Office folder (not
something I'd do on a production server), but no go!

Does anyone know which file needs permission? Any other suggestions?

Thanks in advance,

Stuart


====================================================================
The error:
Access is denied.
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.UnauthorizedAccessException: Access is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user (typically
IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add the
appropriate user or group. Highlight the ASP.NET account, and check the
boxes for the desired access.
 
L

Lau Lei Cheong

No. ASPNET is a restricted account that's somewhat like "guest" account. It
cannot be used to execute anything outside your web process.

Instead, you should try to "impersonate"(Google for this keyword for usage)
a real "user" account, and give the "user" permission to that directory too,
of course.
 
S

Stu

Many thanks - that did the trick.

Stu

Lau Lei Cheong said:
No. ASPNET is a restricted account that's somewhat like "guest" account.
It cannot be used to execute anything outside your web process.

Instead, you should try to "impersonate"(Google for this keyword for
usage) a real "user" account, and give the "user" permission to that
directory too, of course.
 
S

Stu

Many thanks - that did the trick.

Stu

Lau Lei Cheong said:
No. ASPNET is a restricted account that's somewhat like "guest" account.
It cannot be used to execute anything outside your web process.

Instead, you should try to "impersonate"(Google for this keyword for
usage) a real "user" account, and give the "user" permission to that
directory too, of course.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top