Click here to Skip to main content
15,896,453 members
Articles / Programming Languages / C#

A ContactLOB line-of-business application sample - Login: Silverlight, MVVM, WCF RIA Services

Rate me:
Please Sign up or sign in to vote.
4.78/5 (7 votes)
20 Feb 2012CPOL6 min read 35.8K   1.1K   10  
A Silverlight LOB application tutorial.
using System.Security.Principal;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server.ApplicationServices;

namespace ContactLOB.Web.Services
{
	/// <summary>
	/// RIA Services DomainService responsible for authenticating users when
	/// they try to log on to the application.
	///
	/// Most of the functionality is already provided by the base class
	/// AuthenticationBase
	/// </summary>
	[EnableClientAccess]
	public class AuthenticationDomainService : AuthenticationBase<WebUser>
	{
		protected override WebUser GetAuthenticatedUser(IPrincipal principal)
		{
			// TODO: Add code to retreive user info from database
			WebUser user = new WebUser();
			user.Name = principal.Identity.Name;
			user.FirstName = "Bill";
			user.LastName = "Gates";

			return user;
		}

		protected override bool ValidateUser(string userName, string password)
		{
			// TODO: Add code to check user credentials against database
			string usrName = "demo";
			string pswHash = "fe01ce2a7fbac8fafaed7c982a04e229";
			return (usrName.Equals(userName) && pswHash.Equals(password));
		}
	}

	public class WebUser : UserBase
	{
		public string UserId { get; set; }
		public string FirstName { get; set; }
		public string LastName { get; set; }
		public bool IsAdmin { get; set; }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
BrizkCRM
United States United States
You can contact me using my website: BrizkCRM

Comments and Discussions