By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

"Stu" <s.****@cergis.com> 撰寫於郵件新聞:OT**************@TK2MSFTNGP12.phx.g bl...
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.

Nov 19 '05 #2

P: n/a
Stu
Many thanks - that did the trick.

Stu

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:ev**************@TK2MSFTNGP09.phx.gbl...
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.

"Stu" <s.****@cergis.com>
撰寫於郵件新聞:OT**************@TK2MSFTNGP12.phx.g bl...
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.


Nov 19 '05 #3

P: n/a
Stu
Many thanks - that did the trick.

Stu

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:ev**************@TK2MSFTNGP09.phx.gbl...
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.

"Stu" <s.****@cergis.com>
撰寫於郵件新聞:OT**************@TK2MSFTNGP12.phx.g bl...
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.


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.