Wcf authentication error

Wcf authentication error

Old forum URL: forums.lhotka.net/forums/t/5598.aspx


bgilbert posted on Wednesday, October 15, 2008

I'm in the process of setting up a Wcf host using 3.5.2. I'm using custom authentication and I get this error: "Principal must be of type BusinessPrincipal, not System.Security.Principal.GenericPrincipal"

I've confirmed that the CslaAuthentication key in both config files match. Here's the app.config section of my client:

  <appSettings>
    <add key="CslaAuthentication" value="Csla" />   
    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla"/>
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>

and the web.config in the server:

    <appSettings>
      <add key="CslaAuthentication" value="Csla"/>
    </appSettings>

So why do I get this exception? Any help would be appreciated.

sergeyb replied on Wednesday, October 15, 2008

Do you establish principal on the client side via some sort of Login method?

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: bgilbert [mailto:cslanet@lhotka.net]
Sent: Wednesday, October 15, 2008 12:32 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Wcf authentication error

 

I'm in the process of setting up a Wcf host using 3.5.2. I'm using custom authentication and I get this error: "Principal must be of type BusinessPrincipal, not System.Security.Principal.GenericPrincipal"

I've confirmed that the CslaAuthentication key in both config files match. Here's the app.config section of my client:

  <appSettings>
    <add key="CslaAuthentication" value="Csla" />   
    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla"/>
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>

and the web.config in the server:

    <appSettings>
      <add key="CslaAuthentication" value="Csla"/>
    </appSettings>

So why do I get this exception? Any help would be appreciated.


bgilbert replied on Wednesday, October 15, 2008

I think I see now. Does the login routine and subsequent creation of a principal need to be entirely client-side? Clearly I don't know enough about Wcf here. Is a principal required to be able to talk across the wire?

Thanks,
Barry

sergeyb replied on Wednesday, October 15, 2008

This error is coming from CSLA really, not WCF.  CSLA expects to find a valid principal on the server, but you have not set one on the client.  Login does not need to be client based.  Just look at PTracker.  Call logout first to put unauthenticated principal on the thread/ApplicaitonContext, then fetch your real principal/identity, and put it on the thread/ApplicaitonContext.  You can look at PTracker 3.0 for an example.  In 3.6 incidentally you do not need to call logout first, CSLA does it for you.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: bgilbert [mailto:cslanet@lhotka.net]
Sent: Wednesday, October 15, 2008 1:31 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Wcf authentication error

 

I think I see now. Does the login routine and subsequent creation of a principal need to be entirely client-side? Clearly I don't know enough about Wcf here. Is a principal required to be able to talk across the wire?

Thanks,
Barry


bgilbert replied on Wednesday, October 15, 2008

Great! Adding that Logout routine did the trick.

Thanks a bunch.

Barry

Copyright (c) Marimer LLC