Re: .NET Components in COM+

From: Malcolm Cudworth (MalcolmCudworth_at_discussions.microsoft.com)
Date: 07/06/04


Date: Tue, 6 Jul 2004 06:28:02 -0700

If you need the assembly to run under a different identity than the code remoting into it use WindowsIdentity tokens to impersonate a user.

Basically use the LogonUser function from the win32 api and use the token returned in the impersonation:

i.e.
    LogonUser(sName, sDomain, sPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, oToken)

    oIdentity = New WindowsIdentity(oToken)
    oContext = oIdentity.Impersonate

"Paul Glavich [MVP - ASP.NET]" wrote:

> You can *not* place it in COM+ while you are debugging (ie. just inherit
> from MarshalByref instead of ServicedComponent) or if its just process
> identity you are after, you can do this via either machine.config (in the
> <processModel> section), or you can define a user within IIS or your
> Application Pool that the "anonymous" accounr runs under and enable
> impersonation so it runs under that account.
>
> --
> - Paul Glavich
> Microsoft MVP - ASP.NET
>
>
> "John" <John@discussions.microsoft.com> wrote in message
> news:4E17BA22-E91C-4DD0-AD0E-BEC1D68A2C90@microsoft.com...
> > I am working on a project which consists of ASP.NET to a COM+ component to
> SQL Server. The problem, or annoyance I am having, is that I am unable to
> easily debug the .NET component in COM+. I have to attach to the process by
> opening another instance of Visual Studio, put a break point, and if I find
> a bug, change the code, recompile and then reinstall into the GAC, and
> retest. A process which is not idea for rapid application development. I was
> told the the only reason that the component is in COM+ is that it is able to
> run under and different identity, and for security reasons it must be so.
> >
> > My question is whether putting a .NET compnent into COM+ is a good idea to
> begin with? Is the problem I just describe reason enough to find an
> alternate security model?
> >
> > thanks
> > John
>
>
>



Relevant Pages

  • Re: Service Account replaced by IUSR ??
    ... That should be the only reason why that user would get used at all. ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... in order to avoid impersonation I did the following: ... - create a service account, register it in AD using the setspn.exe tool ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Impersonation and LinkLabels result in SecurityException
    ... Windows-user. ... The impersonation token is created with a P/Invoke on ... registry access fails when impersonating, ... dwComponentID, Int32 reason, Int32 pvLoopData) ...
    (microsoft.public.dotnet.languages.csharp)
  • Impersonation and LinkLabels result in SecurityException
    ... Windows-user. ... The impersonation token is created with a P/Invoke on ... registry access fails when impersonating, ... dwComponentID, Int32 reason, Int32 pvLoopData) ...
    (microsoft.public.dotnet.general)
  • Re: how do you get current username in aspx?
    ... The reason why I'm on this ride is I can't actually ... impersonation is being used. ... The following should help explain the different scenarios: ...
    (microsoft.public.dotnet.framework)