ASP.NET, C#, AccessDenied problem...

  • Thread starter Thread starter Denis Brkljacic
  • Start date Start date
D

Denis Brkljacic

Hi,


Please, could anybody help me out to fix this... When I put this code:

Process [] aProcesses = Process.GetProcesses();
foreach (Process proc in aProcesses)
{
if (proc.MainModule.BaseAddress.ToInt32() == ExcelH)
{
Temp = proc;
}
}

What I get is error, Access Denied. What could I do to fix this, please?

My intention here was to browse through the processes and find the one that
matches Excel process (ExcelH = objExcel.Hinstance;

Thanks a lot,

/Denis
 
Hi,

The user account under which the asp.net process is running does not have
enough privileges. you could use impersonation for this.

do not elevate the asp.net default user to admin, this could be a problem
down the line.


cheers,
 
Thank you, I have already set impersonation, but the problem is still there
:(

I'm using IUSR_* for accessing my pages, maybe the problem is somewhere
here?



Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

The user account under which the asp.net process is running does not have
enough privileges. you could use impersonation for this.

do not elevate the asp.net default user to admin, this could be a problem
down the line.


cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



Denis Brkljacic said:
Hi,


Please, could anybody help me out to fix this... When I put this code:

Process [] aProcesses = Process.GetProcesses();
foreach (Process proc in aProcesses)
{
if (proc.MainModule.BaseAddress.ToInt32() == ExcelH)
{
Temp = proc;
}
}

What I get is error, Access Denied. What could I do to fix this, please?

My intention here was to browse through the processes and find the one
that
matches Excel process (ExcelH = objExcel.Hinstance;

Thanks a lot,

/Denis
 
Denis Brkljacic said:
Hi,


Please, could anybody help me out to fix this... When I put this code:

Process [] aProcesses = Process.GetProcesses();
foreach (Process proc in aProcesses)
{
if (proc.MainModule.BaseAddress.ToInt32() == ExcelH)
{
Temp = proc;
}
}

What I get is error, Access Denied. What could I do to fix this, please?

My intention here was to browse through the processes and find the one
that
matches Excel process (ExcelH = objExcel.Hinstance;

Thanks a lot,

/Denis

Not sure what you are trying to achieve, but I see a a number of problems
here.
1. ASP.NET is not privileged to enumerate ProcessModule properties, this is
a super privilege held by debug users (SeDebugPrivilege) only.
2. BaseAddress is the start address of the module and has nothing to do with
Hinstance (instance handle).
3. It's a bad idea to use Office application from asp.net (or any other
server based application).

Why not simply use Process.GetProcessesByName("excel") to get an instance of
the excel process?

Willy.
 
Thanks Willy,

Hmmm.... but if I used this:

Process.GetProcessesByName("excel")

I still could not find right this thread's EXCEL instance.
I would run into problem because there could be more than one EXCEL opened
at the time (maybe some user is just using this ASP.NET application and thus
deals with another instance of Excel). I must not close some other thread's
Excel instance, but just this one that is currently used.




Willy Denoyette said:
Denis Brkljacic said:
Hi,


Please, could anybody help me out to fix this... When I put this code:

Process [] aProcesses = Process.GetProcesses();
foreach (Process proc in aProcesses)
{
if (proc.MainModule.BaseAddress.ToInt32() == ExcelH)
{
Temp = proc;
}
}

What I get is error, Access Denied. What could I do to fix this, please?

My intention here was to browse through the processes and find the one
that
matches Excel process (ExcelH = objExcel.Hinstance;

Thanks a lot,

/Denis

Not sure what you are trying to achieve, but I see a a number of problems
here.
1. ASP.NET is not privileged to enumerate ProcessModule properties, this is
a super privilege held by debug users (SeDebugPrivilege) only.
2. BaseAddress is the start address of the module and has nothing to do with
Hinstance (instance handle).
3. It's a bad idea to use Office application from asp.net (or any other
server based application).

Why not simply use Process.GetProcessesByName("excel") to get an instance of
the excel process?

Willy.
 
Back
Top