impersonate problem

Z

zino

Win2000, ASP.Net 1.1
the web application on server (A) read/write to a folder on another server
(B) on same network .
I create 2 similar accounts : on web server (A) and server (B)
with the same username, password ....
NTFS Permissions is assigned .

in the web config file :
impersonation is enabled, and the application accesses the resources using
the new created account credentials

when I run the application (even locally) , I get "you are not authorized to
view this page ...."

do I need to change machine.config file username and password to match the
newly created account, and does that affect other web application running on
the web server (too many) ????

thanks for help
 
K

Kevin Yu [MSFT]

Hi Zino,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
M

[MSFT]

Hello,

How did you access the files on another server? If you remove related code
temporarily, will the web application work? Can you post your web.config
for further research?

BTW, this kind of problem may be related to that the Local Service and
Network Service accounts do not have Full Control to the "Temporary ASP.NET
Files" folder or the network shared folder, you may first try to grant such
permission to see if it will help.

Luke
 
Z

zino

I beleive the problem started when I added a reference to Microsoft.Office to
the application, and not from impersonation, because the first version I
published on the web server, didn't have a reference to Office and though we
didn't have any problem with permissions.
but but I still don't know how to fix it.
following is some of what's in the web config file, and the code behind.

the web config file contains:
<authentication mode="None" />
<identity impersonate="true" userName="domainName\NTusername"
password="NTuserpassword" />

<authorization>
<allow users="*" />
</authorization>


NTusername is an nt user known on all machine in this domain



I added the following references:
- Excel
- Microsoft.Office.Core
- .... ... .... ....


in the code behind, in the imports section:
- Imports System.IO
- Imports Microsoft.Office.Interop
- .... .... ... ..

the "Not authorized" page appear when I try to call the default page that
does not contains any code, (just a welcome message), that's why I beleive
it's a reference problem.


thanks for your help
 
M

[MSFT]

Office interop needs more permission than a normal ASP .NET app. Is the
account "domainName\NTusername" a local administrator? If not, you may try
to add it and see if this will help.

Luke
 
Z

zino

I gave the account under which the application is running (impersonating) an
adminsitrator privilege.
that's solve part of the problem:
1- if I request the page as : http://serverName/applicationName
I get error: "HTTP Error 403 - Forbidden"

2- if I request the page as: http://serverName/applicationName/anyPage.aspx
it run correctly

even when I'm logged to the server and I try to browse a page from IIS
(right click/browse) , the page run correctly , but if I try to browse the
site (from the left pane) I still getting the error

I assigned the account all NT permissions on the physical folder.


thanks for help
 
M

[MSFT]

How did you set the default page for the site? For example, if you set the
default page to anyPage.aspx in IIS, and then browse to the site, will it
be success?

Luke
 
Z

zino

anyPage.aspx is set as default page, and still when I browse to the site
(either ffrom a remote machine, or from IIS directly(locally) ), if I right
click the site (left pane in IIS) and browse, the error occured, but if I
click on the page and browse, it work correctly.

I don't know if the following, is the reason but :
Microsof office that is running on the server where the application is, is
running under different account than the one that the application is
impersonating.
What I mean: is it possible that the application, in order to work
correctly, needs to impersonate the SAME ACCOUNT, that Microsoft Office is
currently runnning under ????

thanks
 
M

[MSFT]

Hello,

If the ASP.NET app's account is a local administrator, it is enough to
invoke the Office component. We don't need impersonate as the one Microsoft
Office is currently runnning under. To confirm this, you can close all
Office process on the server and test again.

Regarding the problem, is there any more information with the error "HTTP
Error 403 - Forbidden"? For example, "Execute Access Denied"? or "SSL
require"? Is the virtual folder has been enabled as a IIS app? If you
create a virtual directory, create a new asp.net application in it, will it
work?

Luke
 
Z

zino

I uninstall the Office XP PIAs and re-install it back.
I don't have the denied error anymore, but there is another new error:


"QueryInterface for interface Microsoft.Office.Interop.Excel._Application
failed"

Stack Trace:
[InvalidCastException: QueryInterface for interface
Microsoft.Office.Interop.Excel._Application failed.]
Microsoft.Office.Interop.Excel.ApplicationClass.get_Workbooks() +0
WeekendScript.RefreshDatabase.readButton_Click1(Object sender, EventArgs
e) +138
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277



(RefreshDatabase is the page name, and weekendScript is the app. name)


and here what inside readButton_click event:
Protected Sub readButton_Click1(ByVal sender As Object, ByVal e As
System.EventArgs) Handles readButton.Click

Dim link As String
Dim i, max_row, max_col As Int16
Dim xl As New Excel.Application
Dim wb As Excel.Workbook = xl.Workbooks.Open("c:\excelFilePath.xls")

xl.DisplayAlerts = False
Dim ws As Excel.Worksheet = xl.ActiveSheet

Dim ds As New DataSet
Dim dt As New DataTable

ds = GetTableShema() ' function to get a table shema ..... ... ...

For Each ws In xl.Worksheets
max_row = ws.UsedRange.Rows.Count
max_col = ws.UsedRange.Columns.Count

For i = 7 To max_row
link = "F" & i
If ws.Range(link).Hyperlinks.Count > 0 Then
Dim dr As DataRow
dr = ds.Tables(0).NewRow
dr(0) = ws.Range(link).Hyperlinks(1).Address()
ds.Tables(0).Rows.Add(dr)
End If
Next
Next

xl.Quit()
End Sub

thanks for help
 
M

[MSFT]

From the error information, the interface of Excel cannot be found. It
seems there are some problem in system registry during Office Installation.
Can you create an Excel object in another application, for example, in a
VBscript file?

Luke
 

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

Similar Threads


Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top