Timer Thread Identity

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • brian

    #1

    Timer Thread Identity

    I have an ASP.Net application that uses impersonation.
    This works fine for accessing/executing the application.
    However, the app utilizes a timer, that when fired uses
    the <machine>ASPN ET identity.

    In order to correct this problem I've modified the
    Machine.config file in the
    \Microsoft.Net\ Framework\v1.1. 4322 folder. However, this
    didn't solve the problem; instead of using the user id and
    password specified in Machine.Config, the thread executed
    with <machine>ASPN ET identity.

    I sure would appreciate it if someone could shine some
    light on this issue for me.

    Thanks.

    brian
  • Willy Denoyette [MVP]

    #2
    Re: Timer Thread Identity

    Timer delegates are run on threadpool threads, these are running in the security context of the process (asp.net) not the context of
    the calling thread.
    There is nothing you can do about this.
    Question you should ask yourself:
    - why do you use timers in asp.net applications in the first place, and second why do you execute code in a timer event handler
    which requires a certain security context?

    Willy.

    "brian" <bdavis@palcote lecom.com> wrote in message news:048a01c37e e2$d4da2280$a40 1280a@phx.gbl.. .[color=blue]
    > I have an ASP.Net application that uses impersonation.
    > This works fine for accessing/executing the application.
    > However, the app utilizes a timer, that when fired uses
    > the <machine>ASPN ET identity.
    >
    > In order to correct this problem I've modified the
    > Machine.config file in the
    > \Microsoft.Net\ Framework\v1.1. 4322 folder. However, this
    > didn't solve the problem; instead of using the user id and
    > password specified in Machine.Config, the thread executed
    > with <machine>ASPN ET identity.
    >
    > I sure would appreciate it if someone could shine some
    > light on this issue for me.
    >
    > Thanks.
    >
    > brian[/color]


    Comment

    • brian

      #3
      Re: Timer Thread Identity

      Willy. The reason I am using a timer is that I have users
      adding records to a folder. It is important that the
      contents of this folder be written to SQL Server on a
      regular interval, hence the timer. However, you do make at
      least one valid point; why use a timer? Granted this tool
      is available for me to use, but I could just as easily use
      a counter, and write the contents of the folder to SQL
      Server everytime the document count reaches 100.

      brian

      [color=blue]
      >-----Original Message-----
      >Timer delegates are run on threadpool threads, these are[/color]
      running in the security context of the process (asp.net)
      not the context of[color=blue]
      >the calling thread.
      >There is nothing you can do about this.
      >Question you should ask yourself:
      >- why do you use timers in asp.net applications in the[/color]
      first place, and second why do you execute code in a timer
      event handler[color=blue]
      >which requires a certain security context?
      >
      >Willy.
      >
      >"brian" <bdavis@palcote lecom.com> wrote in message[/color]
      news:048a01c37e e2$d4da2280$a40 1280a@phx.gbl.. .[color=blue][color=green]
      >> I have an ASP.Net application that uses impersonation.
      >> This works fine for accessing/executing the application.
      >> However, the app utilizes a timer, that when fired uses
      >> the <machine>ASPN ET identity.
      >>
      >> In order to correct this problem I've modified the
      >> Machine.config file in the
      >> \Microsoft.Net\ Framework\v1.1. 4322 folder. However, this
      >> didn't solve the problem; instead of using the user id[/color][/color]
      and[color=blue][color=green]
      >> password specified in Machine.Config, the thread[/color][/color]
      executed[color=blue][color=green]
      >> with <machine>ASPN ET identity.
      >>
      >> I sure would appreciate it if someone could shine some
      >> light on this issue for me.
      >>
      >> Thanks.
      >>
      >> brian[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Willy Denoyette [MVP]

        #4
        Re: Timer Thread Identity

        Brian,
        The purpose of my question was, how do you synchronize both, the service time (time to handle the asp request) and the timer
        interval?
        If the former is shorter than the latter, your page object could be GC'd before the timer expires, unless you take some precautions,
        you will lose the timer event.
        A possible solution to your problem windows identity doesn't flow when using threadpool threads (and delegates)' is to move (part
        of) your DB updates to a COM+ server-type component (ServicedCompon ent) running with a fixed identity.
        Each time the timer fires you simply call (synchronously) a method on the component, you could even make the call asynchronous by
        using MSMQ.

        Willy.



        "brian" <bdavis@palcote lecom.com> wrote in message news:05ca01c37f 9e$798bef00$a00 1280a@phx.gbl.. .[color=blue]
        > Willy. The reason I am using a timer is that I have users
        > adding records to a folder. It is important that the
        > contents of this folder be written to SQL Server on a
        > regular interval, hence the timer. However, you do make at
        > least one valid point; why use a timer? Granted this tool
        > is available for me to use, but I could just as easily use
        > a counter, and write the contents of the folder to SQL
        > Server everytime the document count reaches 100.
        >
        > brian
        >
        >[color=green]
        > >-----Original Message-----
        > >Timer delegates are run on threadpool threads, these are[/color]
        > running in the security context of the process (asp.net)
        > not the context of[color=green]
        > >the calling thread.
        > >There is nothing you can do about this.
        > >Question you should ask yourself:
        > >- why do you use timers in asp.net applications in the[/color]
        > first place, and second why do you execute code in a timer
        > event handler[color=green]
        > >which requires a certain security context?
        > >
        > >Willy.
        > >
        > >"brian" <bdavis@palcote lecom.com> wrote in message[/color]
        > news:048a01c37e e2$d4da2280$a40 1280a@phx.gbl.. .[color=green][color=darkred]
        > >> I have an ASP.Net application that uses impersonation.
        > >> This works fine for accessing/executing the application.
        > >> However, the app utilizes a timer, that when fired uses
        > >> the <machine>ASPN ET identity.
        > >>
        > >> In order to correct this problem I've modified the
        > >> Machine.config file in the
        > >> \Microsoft.Net\ Framework\v1.1. 4322 folder. However, this
        > >> didn't solve the problem; instead of using the user id[/color][/color]
        > and[color=green][color=darkred]
        > >> password specified in Machine.Config, the thread[/color][/color]
        > executed[color=green][color=darkred]
        > >> with <machine>ASPN ET identity.
        > >>
        > >> I sure would appreciate it if someone could shine some
        > >> light on this issue for me.
        > >>
        > >> Thanks.
        > >>
        > >> brian[/color]
        > >
        > >
        > >.
        > >[/color][/color]


        Comment

        Working...