impersonation

J

Jim McGivney

In an aspx page I have a datagrid populated by an oledbDataAdaptor and
dataset from a Microsoft Access database.
When the line <identity impersonate="true" /> is placed in the web.config ,
I am able to populate and view the datagrid. I am also able to add a new
record to the datagrid by using:
this.dateSett11.Table1.Rows.InsertAt(dr, 9999999);
DataAdaptDA.Update(dateSett11);

When I remove the line <identity impersonate="true" /> from web.config , I
can populate and view the datagrid but when I try to add a record, I get the
error:
The Microsoft Jet database engine cannot open the file
'C:\Inetpub\wwwroot\testo\DatsDB.mdb'. It is already opened exclusively by
another user, or you need permission to view its data.
This posting may show my limited understanding of permissions,
never-the-less I would like to find out what I must do to be able to write
to the dataset without using impersonation. Where do I set or change the
premissions ?
Thanks in advance for your help,
Jim
 
S

S. Justin Gengo

You need to give the user account your website is running as a minimum of
modify permissions on the .mdb database file. When identity impersonate =
true is used then the web site is running as the ASPNET account on a windows
xp box normally the website runs as IUSR_[MachineName] when identity
impersonate is set to false (or not included). You can take care of this in
a couple of different ways. You could create a new account for the website
to run as and then give that account modify permissions to the .mdb file, or
you could just give the IUSR_[MachineName] account modify permissions to the
..mdb file.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

Juan T. Llibre

re:
When I remove the line <identity impersonate="true" /> from web.config ,
I can populate and view the datagrid but when I try to add a record,
I get the error:
I would like to find out what I must do to be able to write to the dataset
without using impersonation. Where do I set or change the permissions ?

Hi, Jim.

You're going to have to detect the account under
which ASP.NET is running when it is not being impersonated.

Save the following as identity.aspx and run it *without* enabling impersonation.

identity.aspx
-------------------
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
------------------

When you run that file, it will return the current ASP.NET identity,
i.e., the account ASP.NET is running as, when not impersonating.

Give *that* account the access permissions to the directory and file.

To assign the necessary ASP.NET permissions to that account, so that
the default directories ASP.NET needs are allowed access when you're
running "ordinary" ASP.NET files, run the following command from a
command window in the .Net Framework directory :

aspnet_regiis -ga MachineName\AccountName

(Write whatever machine and account name the identity.aspx file returned.)

Doing that should set you up as ready to go...
 
P

Paul Clement

¤ In an aspx page I have a datagrid populated by an oledbDataAdaptor and
¤ dataset from a Microsoft Access database.
¤ When the line <identity impersonate="true" /> is placed in the web.config ,
¤ I am able to populate and view the datagrid. I am also able to add a new
¤ record to the datagrid by using:
¤ this.dateSett11.Table1.Rows.InsertAt(dr, 9999999);
¤ DataAdaptDA.Update(dateSett11);
¤
¤ When I remove the line <identity impersonate="true" /> from web.config , I
¤ can populate and view the datagrid but when I try to add a record, I get the
¤ error:
¤ The Microsoft Jet database engine cannot open the file
¤ 'C:\Inetpub\wwwroot\testo\DatsDB.mdb'. It is already opened exclusively by
¤ another user, or you need permission to view its data.
¤ This posting may show my limited understanding of permissions,
¤ never-the-less I would like to find out what I must do to be able to write
¤ to the dataset without using impersonation. Where do I set or change the
¤ premissions ?
¤ Thanks in advance for your help,
¤ Jim
¤

See the following:

PRB: Cannot connect to Access database from ASP.NET
http://support.microsoft.com/?scid=kb;en-us;316675&spid=2514&sid=300


Paul
~~~~
Microsoft MVP (Visual Basic)
 

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

Newbie question about impersonation 5
Impersonation 0
Impersonation 1
Impersonation and Session_End() 1
Impersonation? 1
Impersonation 0
asp.net impersonation 1
Get infor for impersonation. 0

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,130
Latest member
MitchellTe
Top