New Posts New Posts RSS Feed: PersistenceSecurityException
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

PersistenceSecurityException

 Post Reply Post Reply
Author
energysaver View Drop Down
Newbie
Newbie


Joined: 13-Aug-2013
Posts: 6
Post Options Post Options   Quote energysaver Quote  Post ReplyReply Direct Link To This Post Topic: PersistenceSecurityException
    Posted: 13-Aug-2013 at 12:20pm
I'm getting the following exception when I attempt to query one of my entities:

PersistenceSecurityException: User is not authorized for this type

The generated class for the entity looks like this:

  [DataContract(IsReference=true)]
  [IbEm.DataSourceKeyName(@"MyContext")]
  [IbEm.DefaultEntitySetName(@"MyContext.MyEntity")]
  [IbEm.ClientCanQuery(true)]
  [IbEm.ClientQueryPermissions(IbEm.ClientQueryPermissions.AllowIncludes | IbEm.ClientQueryPermissions.AllowProjections)]
  [IbEm.ClientCanSave(true)]
  public partial class MyEntity : IbEm.Entity
  {
     ...
  }

The partial class looks like this:

  public partial class MyEntity : IbEm.Entity
  {
     ...
  }

The [RequiresAuthentication] attribute is NOT present on the class.

None of my queries throws this exception when I pass a non-null login credential to Authenticator.Instance.LoginAsync. The exception occurs ONLY when I pass in a null credential. When the exception occurs, the AuthenticationContext of the entity manager indicates the I am logged in as Anonymous / Guest - 1.

I tried adding this to my web.config:

    <objectServer>
      <serverSettings allowAnonymousLogin="true" useAspNetSecurityServices="true"/>
    </objectServer>

It didn't help.

I tried inheriting from EntityServerQueryInterceptor and setting DefaultAuthorization to false and ShouldAuthorizeQueryResult to false and AuthorizeQuery to true.

That didn't help either. (And I saw no indication that DevForce ever picked up on my interceptor.)

My Silverlight app is based on the TempHire sample Cocktail app, where the domain model is in one assembly with links to its classes in a separate SL assembly, which is subsequently referenced by the Silverlight assembly.

Any suggestions on how to solve this? The contents of the server log file near where the exception occurs appears below.

Thanks in advance.

<entry id="6" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.IdeaBladeConfig:InitializationStatusCallback">IdeaBlade License: 'DataCenterServer, Universal', KeyDate: 7/10/2013, AllowedSessions: 10000. Found on Assembly: 'My.DataServices.CustomApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'</entry>
<entry id="7" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Configuration.ServerSettingsElement:ConstrainSettingsBasedOnLicenseCore">The configured SupportedClientApplicationType is All</entry>
<entry id="8" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckMultiExport">CompositionContext: 'IbDefault' - Probed for non-default 'ITraceLoggerProvider' and found 'Cocktail.TraceLoggerProvider'.</entry>
<entry id="10" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.TraceFns:CompleteTracingInitialization">IdeaBladeConfig resolution: File: C:\My.NET\MyApp.Development\MyApponline.Web\web.config - found</entry>
<entry id="11" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.TraceFns:CompleteTracingInitialization">IdeaBladeConfig resolution: Logging file: C:\My.NET\MyApp.Development\MyApponline.Web\log\DevForceDebugLog.xml</entry>
<entry id="12" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.TraceFns:CompleteTracingInitialization">Bound to .NET runtime version 4.0.30319.18213</entry>
<entry id="13" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.TraceFns:CompleteTracingInitialization">DevForce Version=7.2.0.0</entry>
<entry id="14" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.RemoteServiceFns:AddSerializationBehavior">Using DC serializer for EntityService</entry>
<entry id="15" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckSingleExport">CompositionContext: 'IbDefault' - Probed for any 'ServiceHostEvents' and found 'IdeaBlade.EntityModel.Server.ServiceHostEvents'.</entry>
<entry id="16" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Server.EntityServiceHostFactory:CreateServiceHost">EntityService listening on http://localhost:9009/EntityService.svc</entry>
<entry id="17" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Server.EntityServiceHostFactory:CreateServiceHost">EntityService listening on http://localhost:9009/EntityService.svc/winrt</entry>
<entry id="18" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Server.EntityServiceHostFactory:CreateServiceHost">EntityService listening on http://localhost:9009/EntityService.svc/wp</entry>
<entry id="19" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Server.EntityServiceHostFactory:CreateServiceHost">EntityService listening on http://localhost:9009/EntityService.svc/sl</entry>
<entry id="20" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckSingleExport">CompositionContext: 'IbDefault' - Probed for any 'EntityServiceApplication' and found 'IdeaBlade.EntityModel.EntityServiceApplication'.</entry>
<entry id="21" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.EntityServiceApplication:OnServiceStartup">EntityService created</entry>
<entry id="22" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Server.EntityServer:.ctor">EntityServer created for DataSourceExtension: [None], CompositionContext: IbDefault</entry>
<entry id="23" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckMultiExport">CompositionContext: 'IbDefault' - Probed for any 'ICompositionContextResolver' and found no matching exports.</entry>
<entry id="24" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckSingleExport">CompositionContext: 'IbDefault' - Probed for default 'IDataSourceKeyResolver' and found 'IdeaBlade.EntityModel.DefaultDataSourceKeyResolver'.</entry>
<entry id="25" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckMultiExport">CompositionContext: 'IbDefault' - Probed for any 'IEntityQueryExecutor' and found 'IdeaBlade.EntityModel.Edm.EdmQueryExecutor'.</entry>
<entry id="26" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckMultiExport">CompositionContext: 'IbDefault' - Probed for any 'IEntityQueryExecutor' and found 'IdeaBlade.EntityModel.Edm.PassthruEsqlQueryExecutor'.</entry>
<entry id="27" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckMultiExport">CompositionContext: 'IbDefault' - Probed for any 'IEntityQueryExecutor' and found 'IdeaBlade.EntityModel.Edm.StoredProcQueryExecutor'.</entry>
<entry id="28" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckMultiExport">CompositionContext: 'IbDefault' - Probed for any 'IEntityQueryExecutor' and found 'IdeaBlade.EntityModel.Edm.UdtQueryExecutor'.</entry>
<entry id="29" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Server.SessionManager:GetLoginManager">Anonymous access: enabled</entry>
<entry id="30" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckSingleExport">CompositionContext: 'IbDefault' - Probed for non-default 'IEntityLoginManager' and found no matching exports.</entry>
<entry id="31" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Server.SessionManager:GetLoginManager">Looking for AspAuthenticatingLoginManager</entry>
<entry id="32" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Web.AspAuthenticatingLoginManager:.ctor">ASP.NET security service integration enabled</entry>
<entry id="33" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.EntityModel.Web.AspAuthenticatingLoginManager:.ctor">ASP.NET authentication mode: Forms</entry>
<entry id="34" timestamp="2013-08-13T11:55:43" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckSingleExport">CompositionContext: 'IbDefault' - Probed for default 'IEntityLoginManager' and found 'IdeaBlade.EntityModel.Web.AspAuthenticatingLoginManager'.</entry>
<entry id="35" timestamp="2013-08-13T11:55:45" username="" source="IdeaBlade.Core.Composition.CompositionHost:CheckMultiExport">CompositionContext: 'IbDefault' - Probed for non-default 'IKnownTypeProvider' and found no matching exports.</entry>
<entry id="36" timestamp="2013-08-13T11:55:45" username="" source="IdeaBlade.EntityModel.RemoteServiceFns:AddSerializationBehavior">Using DC serializer for EntityServer</entry>
<entry id="37" timestamp="2013-08-13T11:55:45" username="" source="IdeaBlade.EntityModel.Server.EntityServerHostFactory:CreateServiceHost">EntityServer listening on http://localhost:9009/EntityServer.svc</entry>
<entry id="38" timestamp="2013-08-13T11:55:45" username="" source="IdeaBlade.EntityModel.Server.EntityServerHostFactory:CreateServiceHost">EntityServer listening on http://localhost:9009/EntityServer.svc/winrt</entry>
<entry id="39" timestamp="2013-08-13T11:55:45" username="" source="IdeaBlade.EntityModel.Server.EntityServerHostFactory:CreateServiceHost">EntityServer listening on http://localhost:9009/EntityServer.svc/wp</entry>
<entry id="40" timestamp="2013-08-13T11:55:45" username="" source="IdeaBlade.EntityModel.Server.EntityServerHostFactory:CreateServiceHost">EntityServer listening on http://localhost:9009/EntityServer.svc/sl</entry>
<entry id="41" timestamp="2013-08-13T11:55:46" username="" source="IdeaBlade.EntityModel.EntityServerProxy:GetInstance">Loaded IdeaBlade.EntityModel.LocalEntityServerProxy</entry>
<entry id="42" timestamp="2013-08-13T11:55:54" username="" source="IdeaBlade.EntityModel.EntityMetadataStore:LoadMetadataFromEmbeddedResources">No metadata resources found in 'My.DataServices.CustomApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'</entry>
<entry id="43" timestamp="2013-08-13T11:55:54" username="Guest - 1" source="IdeaBlade.Core.Composition.CompositionHost:CheckSingleExport">CompositionContext: 'IbDefault' - Probed for any 'EntityServerQueryInterceptor' and found 'IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor'.</entry>
<entry id="44" timestamp="2013-08-13T11:55:55" username="Guest - 1" source="IdeaBlade.Core.Composition.CompositionHost:CheckSingleExport">CompositionContext: 'IbDefault' - Probed for any 'EntityServerErrorInterceptor' and found 'IdeaBlade.EntityModel.Server.EntityServerErrorInterceptor'.</entry>
<entry id="45" timestamp="2013-08-13T11:55:55" username="Guest - 1" source="IdeaBlade.EntityModel.Server.EntityServerErrorInterceptor:OnError">Caught exception: System.UnauthorizedAccessException: User is not authorized for this type
   at IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor.HandleException(Exception e, PersistenceFailure failureType)
   at IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor.OnAuthorizeQuery()
   at IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor.Execute(IEntityQuery entityQuery, SessionBundle sessionBundle, IEntityServer entityServer)
   at IdeaBlade.EntityModel.Server.EntityServer.Fetch(SessionBundle sessionBundle, IEntityQuerySurrogate surrogate)
   at SyncInvokeFetch(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</entry>
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 13-Aug-2013 at 3:15pm
This is weird.  DevForce only throws that specific exception message if it's found an AuthorizationAttribute of some kind on the type.
 
Is there any possibility that the changes you're making - to the MyEntity type definition, and also the custom EntityServerQueryInterceptor which isn't being found - haven't actually been deployed to your server? 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down