Inhoud blog
  • ASP.NET - Asynchronous call to a webservice with impersonation
  • ASP.NET - Custom object as parameter for ObjectDataSource
  • ASP.NET - Identity impersonation
  • MyCalendar - add events without postbacks
  • ASP..NET Web Parts
    Zoeken in blog

    My Profile
  • LinkedIn
  • My Favorite Blogs
  • Kevin DeRudder
  • Rudi Larno
  • David Hayden
  • David Cumps
  • Reinout's blog
    Talking about new features, useful things, frustrations in .NET and so on...
    06-09-2007
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.ASP.NET - Asynchronous call to a webservice with impersonation
    I stumbled across something annoying on my crusade through the forest of webservices today.

    When impersonation is enabled, the running thread obtains the identity configured in the web.config file. Not much to worry form then, calling webservices will be running in the same context.

    This behaviour is nice and easy, until you implement an asynchronous call to a webservice or an asynchronous call to a data source. Impersonation is not inherited from the calling thread, which might deliver unexpected results, by some called exceptions, errors or whatever. (InvalidOperationException is the most likely exception to be thrown.)

    To prevent that, get the current identity before the BeginInvoke method, supply it as a parameter to the delegate method and set the impersonation context in the other thread. Perform some other context or session related stuff if needed and load your data. Don't forget to call the Undo() method in a finally block to restore the previous security context.

    That's it !

    web.config :
    impersonate

    Web method :
    web methods

    Calling method :
    web service

    Of course you can also call the webservice itself asynchronously, by adopting a similar code as seen above in the web method. Again all that's needed is to impersonate the WindowsIdentity in the context before calling the BeginInvoke method and end with the Undo() method.

    06-09-2007 om 00:00 geschreven door Reinout Waelput  


    05-09-2007
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.ASP.NET - Custom object as parameter for ObjectDataSource

    Lately I heard a remark that it’s not possible to supply other parameters than strings to filter the datasource in order to fill a gridview.
    Since I was quite sure that’s not the case, I accepted the challenge (from myself) to prove him wrong. 

    First add (drag/drop) an ObjectDataSource object to the page or user control.
    Configure the datasource to use a list of objects (here an object of type UserList).

    Business Object

    Now define the (static) method used to load this object.

    Select method used for ObjectDataSource

    This is how the methods in the Business Object look like (just an example).

    Static method in Business Object

    The parameter(-s) will now be visible on the next screen, don’t choose a source in here!

    Parameters used for ObjectDataSource

    After finishing the wizard, the result is this :

    Resulting ObjectDataSource

    Now all that’s required is to modify the InputParameters in the Selecting event of the ObjectDataSource.

    Event to set the parameter

    That's it !

    05-09-2007 om 09:31 geschreven door Reinout Waelput  




    Archief per week
  • 03/09-09/09 2007
  • 27/08-02/09 2007
  • 20/08-26/08 2007
  • 13/08-19/08 2007
  • 06/08-12/08 2007
  • 26/09-02/10 2005

    E-mail mij

    Druk op onderstaande knop om mij te e-mailen.



    Blog tegen de wet? Klik hier.
    Gratis blog op https://www.bloggen.be - Meer blogs