470,593 Members | 2,470 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,593 developers. It's quick & easy.

Access Denied

Hi

In one of our ASP.NET Application web form we are using the
Microsoft.Office.Interop.Word COM DLL. We need to read some word documents
and create rtf files and merge them together into one doc file.

On click of a button the the word application com dll is getting activated,
but wehn we do this on a Windows Server 2003 machine we are getting the
following error.

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.

The COM DLL Microsoft.Word.Document has been given allow permission to the
ASPNET user account.

Can somebody help in setting the right permissions or finding a solution for
this.

This error in generated where the code has the following line
newApp = New Word.Application

Code:
Imports System.Runtime.InteropServices
Imports Word = Microsoft.Office.Interop.Word
Imports Office = Microsoft.Office.Core

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim newApp As Word.ApplicationClass

Dim source As Object = Server.MapPath("/site/Docs/" & sFileName)
Dim target As Object = Server.MapPath("/site/Docs/" & "temDocfile.rtf")

Dim unKnown As Object = Type.Missing

newApp = New Word.Application

newApp.Visible = True
newApp.Documents.Open(source, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown)

Dim objformat As Object = Word.WdSaveFormat.wdFormatRTF

newApp.ActiveDocument.SaveAs(target, objformat, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown)

newApp.ActiveDocument.Close(unKnown, unKnown, unKnown)

newApp.Quit(unKnown, unKnown, unKnown)
newApp = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComO bject(newApp)
newApp = Nothing

End Sub

This code provided is for a testing page we had created where we are trying
to open a word document file and save that as a rtf file.

The folder where these files are opened from and closed have full
permissions to the ASPNet user account.

Thanks in Advance
--
Warm Regards
Deepankar
Nov 18 '05 #1
1 3821
You are using Windows 2003? Try the NetworkService account instead of the
ASPNET account.

- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
"Deepankar Raizada" <De**************@discussions.microsoft.com> wrote in
message news:55**********************************@microsof t.com...
Hi

In one of our ASP.NET Application web form we are using the
Microsoft.Office.Interop.Word COM DLL. We need to read some word documents
and create rtf files and merge them together into one doc file.

On click of a button the the word application com dll is getting activated, but wehn we do this on a Windows Server 2003 machine we are getting the
following error.

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.

The COM DLL Microsoft.Word.Document has been given allow permission to the
ASPNET user account.

Can somebody help in setting the right permissions or finding a solution for this.

This error in generated where the code has the following line
newApp = New Word.Application

Code:
Imports System.Runtime.InteropServices
Imports Word = Microsoft.Office.Interop.Word
Imports Office = Microsoft.Office.Core

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim newApp As Word.ApplicationClass

Dim source As Object = Server.MapPath("/site/Docs/" & sFileName)
Dim target As Object = Server.MapPath("/site/Docs/" & "temDocfile.rtf")

Dim unKnown As Object = Type.Missing

newApp = New Word.Application

newApp.Visible = True
newApp.Documents.Open(source, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown)

Dim objformat As Object = Word.WdSaveFormat.wdFormatRTF

newApp.ActiveDocument.SaveAs(target, objformat, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown)

newApp.ActiveDocument.Close(unKnown, unKnown, unKnown)

newApp.Quit(unKnown, unKnown, unKnown)
newApp = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComO bject(newApp)
newApp = Nothing

End Sub

This code provided is for a testing page we had created where we are trying to open a word document file and save that as a rtf file.

The folder where these files are opened from and closed have full
permissions to the ASPNet user account.

Thanks in Advance
--
Warm Regards
Deepankar

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by calfdog | last post: by
reply views Thread by Steve | last post: by
reply views Thread by ASP.Confused | last post: by
12 posts views Thread by Ron Weldy | last post: by
3 posts views Thread by Shailesh Humbad | last post: by
3 posts views Thread by David Thielen | last post: by
8 posts views Thread by Jeremy Ames | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.