Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

COM+ Application Libary/Server Activation

I have created a serviced component using VB.NET. I have set the Actication type to Library and create a test application using normal exe. It works..

But when I call it from ASP.NET it fails with the following error :=

Server Error in '/WebApplication1' Application.
--------------------------------------------------------------------------------

Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access is denied.

The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

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 "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.

Source Error:


Line 25:         Dim a As ClassLibrary1.Poolable
Line 26:
Line 27:         a = New ClassLibrary1.Poolable()
Line 28:     End Sub
Line 29: End Class
 

Source File: c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb    Line: 27

Stack Trace:


[UnauthorizedAccessException: Access is denied.]
   System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo) +0
   System.EnterpriseServices.Thunk.Proxy.CoCreateObject(Type serverType, Boolean bQuerySCInfo, Boolean& bIsAnotherProcess, String& uri) +587
   System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Type serverType) +181
   System.Runtime.Remoting.Activation.ActivationServices.CreateInstanceWithLinkDemand(ProxyAttribute pa, Type serverType) +4
   System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props) +122
   WebApplication1.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb:27
   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() +1263

 
I tried changing the Activation to Server and the page works. Why is this happening ? How can I make it work again ? thank you very much..

Need your help..
0
fkmfkm
Asked:
fkmfkm
1 Solution
 
CarlosMuCommented:
Basically the answer to your question lies in the statmenent.

The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

When you run the component from a windows application it is running under the user id of the person log on the machine. That person (you) has the rights to run such an application.  When you run an asp page the process must run under a user id, but since any user migth be accesing the page the user asigned to the page has limited authority.  What you have to do is to assign the proper authority to the dll.  Unfortunately, I have not yet reach that chapter on my book.
0
 
GoodJunCommented:
You can do it through impersonation.
From your web.config file
<identity impersonate=true>
this will use the client identity to run the app. IIS has to set window authentication to use this.

or you can impersonate a user to run this app:
<identity impersonate="true" userName="contoso\Jane" password="pass" />
This enables the entire application to run as contoso\Jane, regardless of the identity of the request, so long as the password is correct. This type of impersonation can be delegated to another computer.

0
 
yositCommented:
u can change the machine.config file
and changin 'machine' to 'SYSTEM'
and it will work
0
[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

 
fkmfkmAuthor Commented:
How should i give the points to GoodJun and yosit ?
0
 
GoodJunCommented:
Did you solved your problem? If not, we can guide you through to make it work.

cheers,
0
 
fkmfkmAuthor Commented:
How if I am doing normal ASP 3.0 pages ?
0
 
GoodJunCommented:
asp 3.0 also support impersonation.
Thanks for the grade.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now