Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you create a "Silverlight Business Application" you'll see how the template implements authentication. (Or just go <a href="http://blogs.msdn.com/brada/archive/2009/07/10/amazing-business-apps-example-updated-for-silverlight-3-rtm-and-net-ria-services-july-update.aspx" rel="noreferrer">here and download the template sample project</a>.)</p> <p>To simplify, here's the process I used:</p> <p>First, I create a domain service (FooService) that derives from LinqToEntitiesDomainService where FooContext is my entity model. In it I add all the CRUD operations to access my custom DB table and return user profiles.</p> <p>Next, create a concrete User class on the serverside by deriving from UserBase:</p> <pre><code>using System.Web.Ria; using System.Web.Ria.ApplicationServices; public class User : UserBase {} </code></pre> <p>Finally, derive a class from AuthenticationBase and implement the following four methods:</p> <pre><code>[EnableClientAccess] public class AuthenticationService : AuthenticationBase&lt;User&gt; { private FooService _service = new FooService(); protected override bool ValidateUser(string username, string password) { // Code here that tests only if the password is valid for the given // username using your custom DB calls via the domain service you // implemented above } protected override User GetAuthenticatedUser(IPrincipal pricipal) { // principal.Identity.Name will be the username for the user // you're trying to authenticate. Here's one way to implement // this: User user = null; if (this._service.DoesUserExist(principal.Identity.Name)) // DoesUserExist() is a call // added in my domain service { // UserProfile is an entity in my DB UserProfile profile = this._service.GetUserProfile(principal.Identity.Name); user.Name = profile.UserName; user.AuthenticationType = principal.Identity.AuthenticationType; } return user; } public override void Initialize(DomainServiceContext context) { this._service.Initialize(context); base.Initialize(context); } protected override void Dispose(bool disposing) { if (disposing) this._service.Dispose(); base.Dispose(disposing); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload