CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Invalid token for impersonation issue.

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 4 Replies | 1 Follower

    Not Ranked
    3 Posts
    sliedig posted on Wed, Mar 24 2010 12:46 PM

    Hello,

    Wondering if someone can help me with an issue I'm having with accessing the data portal.

    We are using CSLA version 3.6.2. with CSLA Authentication for the DataPortal.

    We have developed a Windows Service that is responsible for generation of data sets that are shared amongst a number of clients. The service also hosts a WCF Services that exposes an endpoint that is consumed by a Pub/Sub implementation.

    When the service starts up, it successfully connects to the data portal (via WCF) and builds the available datasets in the system. No problem.

    When a new dataset definition is created by a client, the Windows Service receives the published event via the pub/sub and attempts to build the dataset from the newly created definition which was saved in the database. It at this point that the attempt to access the database fails with an error:

    "Invalid token for impersonation - it cannot be duplicated."

    During the initial call (when the service starts up) the DataPortalContext has no identity. When the callback method is invoked by the pub sub, the DataPortalContext has the identity of the host for the PubSub service. I know this because when I hosted the Pub/Sub service is IIS (via WAS), it tried to access the data portal with the identity IIS APPPOOL.

    My initial solution was to add the following to the callback method

    [OperationBehavior(Impersonation = ImpersonationOption.NotAllowed)]

    This actually worked, at least initially. Now it doesn't and I am not sure why or how to get around the issue of the impersonation token duplication. I've read some previous posts that talk about double hops but I am not sure how to resolve that either.

    Your assistance would be appreciated.

    Regards,

    Steve

    Answered (Verified) Verified Answer

    Not Ranked
    3 Posts
    Verified by sliedig

    Have found an issue to the problem. We have a custom class that inherits from BusinessPrincipalBase and resets the ApplicationContext for the DataPortal to a new unauthenticated identity/principal. This then replaces the security context of the service call and resolves the impersination issue. Hope this helps some else in future.

    Cheers.

    All Replies

    Top 10 Contributor
    4,106 Posts
    Answered (Not Verified) Andy replied on Wed, Mar 24 2010 1:04 PM
    Suggested by Andy

    This sounds like the classic double hop issue.  Using Windows authentication, you can have Windows present a user token for validation to one machine.  Typically you encounter the issue in this scenario:

    Client computer (Web browser) -> Web server (Asp.net using Windows Authentication) -> Data server (Sql Server).

    Each of these is a seperate physical machine.  Windows Auth will have the token passed from client to web server.  The web server will accept it (provided the DC says its a valid token).  But that token CANNOT be handed to the data base server.  That's be design, Windows domains won't allow a duplicated token to be used.

    I suspect you're hitting something similar here.  It sounds like your windows service allows clients to connect via Windows Auth, and the service then turns around and tries to contact the database server, also with Windows auth, which won't be allowed.

    One option is to move the service to run on the database server.  Another might be to prompt of the Windows username / password, then use it to create the principal on the app server using that username password to create a new token, although I don't know if that will work.  If it does, you'll of course have to be careful, because now you're passing Windows logon information around your network..

    Not Ranked
    3 Posts

    Thanks for the suggestions Andy. The Windows Service is running on the same physical machine as the Data Portal. The WCF Service being hosted by the windows service is implementing a callback method which executes logic within it so it can't be moved.

    What I need is a way to stop the credentials from being transferred from the WCF Service host process to the data portal. I thought by implementing the operation behaviour it would do that but for some reason its still coming through.

    I'll take your suggestions on board and see if i can alter the security on the context before calling the data portal.

    Thanks again,

    Steve

    Not Ranked
    3 Posts
    Verified by sliedig

    Have found an issue to the problem. We have a custom class that inherits from BusinessPrincipalBase and resets the ApplicationContext for the DataPortal to a new unauthenticated identity/principal. This then replaces the security context of the service call and resolves the impersination issue. Hope this helps some else in future.

    Cheers.

    Top 10 Contributor
    4,106 Posts
    Andy replied on Thu, Mar 25 2010 7:37 AM

    Ok, so it was the double hop issue then?

    Page 1 of 1 (5 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems