Call function under different security context

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

    #1

    Call function under different security context

    Is there a way in .Net to call a function or web service
    under a different security context as the one that the
    user is logged into?

    For example, if a user calls web service 1 (WS1), WS1 is
    now running under the user's security context. Is there a
    way for WS1 to call another web service, WS2, but to
    impersonate a totally different user account for the call?
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Call function under different security context

    john,

    It depends on the mechanism that is used to authenticate the user on the
    remote web service. If it is using a windows challenge/response mechanism,
    then you will have to change the current user to be the one that you want to
    impersonate. If it is just using basic authentication, then you can just
    set those parameters in the call, and you would not have to change the
    current user that the process is running under.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "john" <john@john.co m> wrote in message
    news:230b01c373 d1$a99e7880$a10 1280a@phx.gbl.. .[color=blue]
    > Is there a way in .Net to call a function or web service
    > under a different security context as the one that the
    > user is logged into?
    >
    > For example, if a user calls web service 1 (WS1), WS1 is
    > now running under the user's security context. Is there a
    > way for WS1 to call another web service, WS2, but to
    > impersonate a totally different user account for the call?[/color]


    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: Call function under different security context

      John,

      Take a look at the documentation for the Impersonate method on the
      WindowsIdentity class. It will detail how you can use a call to the
      LoginUser API function through the P/Invoke layer to get a handle to a user
      that you can impersonate.


      --
      - Nicholas Paldino [.NET/C# MVP]
      - nicholas.paldin o@exisconsultin g.com

      "john" <john@john.co m> wrote in message
      news:225f01c373 db$4d63bd00$a30 1280a@phx.gbl.. .[color=blue]
      > the second WS would use NT authentication to check for
      > access. I dont want the user calling WS1 to have rights
      > to WS2, but i want WS1 to call WS2 and impersonate a new
      > user account. How would i go about doing this?
      >[color=green]
      > >-----Original Message-----
      > >john,
      > >
      > > It depends on the mechanism that is used to[/color]
      > authenticate the user on the[color=green]
      > >remote web service. If it is using a windows[/color]
      > challenge/response mechanism,[color=green]
      > >then you will have to change the current user to be the[/color]
      > one that you want to[color=green]
      > >impersonate. If it is just using basic authentication,[/color]
      > then you can just[color=green]
      > >set those parameters in the call, and you would not have[/color]
      > to change the[color=green]
      > >current user that the process is running under.
      > >
      > > Hope this helps.
      > >
      > >
      > >--
      > > - Nicholas Paldino [.NET/C# MVP]
      > > - nicholas.paldin o@exisconsultin g.com
      > >
      > >"john" <john@john.co m> wrote in message
      > >news:230b01c37 3d1$a99e7880$a1 01280a@phx.gbl. ..[color=darkred]
      > >> Is there a way in .Net to call a function or web service
      > >> under a different security context as the one that the
      > >> user is logged into?
      > >>
      > >> For example, if a user calls web service 1 (WS1), WS1 is
      > >> now running under the user's security context. Is[/color][/color]
      > there a[color=green][color=darkred]
      > >> way for WS1 to call another web service, WS2, but to
      > >> impersonate a totally different user account for the[/color][/color]
      > call?[color=green]
      > >
      > >
      > >.
      > >[/color][/color]


      Comment

      • john

        #4
        Re: Call function under different security context

        Perfect! Thanks
        [color=blue]
        >-----Original Message-----
        >John,
        >
        > Take a look at the documentation for the Impersonate[/color]
        method on the[color=blue]
        >WindowsIdentit y class. It will detail how you can use a[/color]
        call to the[color=blue]
        >LoginUser API function through the P/Invoke layer to get[/color]
        a handle to a user[color=blue]
        >that you can impersonate.
        >
        >
        >--
        > - Nicholas Paldino [.NET/C# MVP]
        > - nicholas.paldin o@exisconsultin g.com
        >
        >"john" <john@john.co m> wrote in message
        >news:225f01c37 3db$4d63bd00$a3 01280a@phx.gbl. ..[color=green]
        >> the second WS would use NT authentication to check for
        >> access. I dont want the user calling WS1 to have rights
        >> to WS2, but i want WS1 to call WS2 and impersonate a new
        >> user account. How would i go about doing this?
        >>[color=darkred]
        >> >-----Original Message-----
        >> >john,
        >> >
        >> > It depends on the mechanism that is used to[/color]
        >> authenticate the user on the[color=darkred]
        >> >remote web service. If it is using a windows[/color]
        >> challenge/response mechanism,[color=darkred]
        >> >then you will have to change the current user to be the[/color]
        >> one that you want to[color=darkred]
        >> >impersonate. If it is just using basic authentication,[/color]
        >> then you can just[color=darkred]
        >> >set those parameters in the call, and you would not[/color][/color][/color]
        have[color=blue][color=green]
        >> to change the[color=darkred]
        >> >current user that the process is running under.
        >> >
        >> > Hope this helps.
        >> >
        >> >
        >> >--
        >> > - Nicholas Paldino [.NET/C# MVP]
        >> > - nicholas.paldin o@exisconsultin g.com
        >> >
        >> >"john" <john@john.co m> wrote in message
        >> >news:230b01c37 3d1$a99e7880$a1 01280a@phx.gbl. ..
        >> >> Is there a way in .Net to call a function or web[/color][/color][/color]
        service[color=blue][color=green][color=darkred]
        >> >> under a different security context as the one that[/color][/color][/color]
        the[color=blue][color=green][color=darkred]
        >> >> user is logged into?
        >> >>
        >> >> For example, if a user calls web service 1 (WS1),[/color][/color][/color]
        WS1 is[color=blue][color=green][color=darkred]
        >> >> now running under the user's security context. Is[/color]
        >> there a[color=darkred]
        >> >> way for WS1 to call another web service, WS2, but to
        >> >> impersonate a totally different user account for the[/color]
        >> call?[color=darkred]
        >> >
        >> >
        >> >.
        >> >[/color][/color]
        >
        >
        >.
        >[/color]

        Comment

        Working...