OleDbConnection - cannot read Excel file

D

dmateer

I have the following code in an asp.net page:

System.Data.OleDb.OleDbConnection cn = new
System.Data.OleDb.OleDbConnection();
cn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\myservername\ExcelTemp\Temp.xls;Extended Properties=Excel
8.0";
cn.Open();
cn.Close();

My IIS site (on localhost) is set to not allow anonymous users,
integrated security. My web.config has the following for impersonation:

<identity impersonate="true" userName="mydomain\workerprocess"
password="mypassword" />

When running this page, I get the helpful
System.Data.OleDb.OleDbException: Unspecified error. There is no record
in the security Event Log of MyServerName that access was attempted.

When I change web.config to:
<identity impersonate="true" />

I get: System.Data.OleDb.OleDbException: The Microsoft Jet database
engine cannot open the file '\\myservername\ExcelTemp\Temp.xls'. It is
already opened exclusively by another user, or you need permission to
view its data.

The security event log records four back-to-back login success audits
coming from my computer, but the user is ANONYMOUS LOGIN. For example:

Event Type: Success Audit
Event Source: Security
Event Category: Logon/Logoff
Event ID: 540
Date: 5/12/2006
Time: 1:43:31 PM
User: NT AUTHORITY\ANONYMOUS LOGON
Computer: MYSERVERNAME
Description:
Successful Network Logon:
User Name:
Domain:
Logon ID: (0x0,0xA685FE4E)
Logon Type: 3
Logon Process: NtLmSsp
Authentication Package: NTLM
Workstation Name: MYCOMPUTERNAME
Logon GUID: -
Caller User Name: -
Caller Domain: -
Caller Logon ID: -
Caller Process ID: -
Transited Services: -
Source Network Address: 10.0.100.100
Source Port: 0

Any ideas how to actually pass the identity being impersonated through
the OleDbConnection? This application reads several SQL Server
databases and everything is working just fine. But I need to read an
Excel file and can't get it to work. Any help would be greatly
appreciated.
 
G

Guest

As with Access databases, a TEMP directory being used. The account under
which the web site is running will probably need full access to the "TEMP"
directory being used. It may be the one under "documents and
settings"\<machinename>\ASPNET\"Local Settings"\Temp....
 
D

dmateer

Brad, your suggestion worked. Thank you so much for your help.

Talk about misleading error messages....

Dave
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top