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
  • Security getting lost when accessing EF6 over WCF

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

    Not Ranked
    4 Posts
    rshuck posted on Fri, Dec 13 2013 9:14 AM

    Firstly let me apologise as I don't believe it is a CSLA issue but an EF6 one.

    I am using CSLA 4.5, EF6 and WCF with IIS Express in VS2012.

    My problem is whenever I add a record in a dataportal_insert EF6 clears the user security so when the response goes back to the client the o:security section of the message is missing which can be seen using svctraceviewer.exe in all prior messages.

    if I comment out the add and savechanges lines all works.

            public void Insert(ProductData productData)
            {
                using (var ctx = DbContextManager<DatabaseContext>.GetManager())
                {
                    ctx.DbContext.Products.Add(new Product().InjectFrom(productData) as Product);
                    ctx.DbContext.SaveChanges();
                }
            }

    I had originally thought it was my web.config settings but after trying countless configs and getting the same results I am now at a loss.  It's Friday and I have spent the last 4 days trying to figure it out and am scared of facing this problem again come Monday.

    Any guidance would severely be appreciated.

    Answered (Verified) Verified Answer

    Not Ranked
    4 Posts
    Answered (Verified) rshuck replied on Mon, Dec 16 2013 10:14 AM
    Verified by rshuck

    An update to let anyone else who has this problem in the future the solution (nobody will ever have this problem i'm sure !)

    It turned out to be due to

                    System.IO.Path.GetDirectoryName(new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath)

    which I was using to get a create a new log file for a trace listener defined in my system.diagnostics section of the web config and without looking I guess doing the reflection thing does something with the current principal.

    Changed to

                    AppDomain.CurrentDomain.BaseDirectory

    And all fixed

    I haven't got unit tests set up (I know, shame on me) but I don't believe any would have found this problem as it only manifested when loading the assembly via ASP.NET.

     

    Page 1 of 1 (2 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