public override string[] GetRolesForUser(string username)
        {
            LinkedList<String> roles = new LinkedList<string>();
            GesLocEntities db = new GesLocEntities();

            Utilisateur u = db.Utilisateurs.SingleOrDefault(x => x.login.Equals(username));
            if (u == null)
                return null;
            else
            {
                if (u.Bailleur != null)
                    roles.AddLast(BAILLEUR);
                else
                    roles.AddLast(LOCATAIRE);
                return roles.ToArray();
            }
        }
 public override bool ValidateUser(string username, string password)
 {
     GesLocEntities db = new GesLocEntities();
     //validate user
     Utilisateur u = db.Utilisateurs.SingleOrDefault(x => x.login.Equals(username) && x.motdepasse.Equals(password));
     return (u != null);
 }
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            var cacheKey = String.Format("UserData_{0}", username);
            if (HttpRuntime.Cache[cacheKey]!=null)
            {
                return (CustomMembershipUser)HttpRuntime.Cache[cacheKey];
            }
            else
            {
                GesLocEntities db = new GesLocEntities();
                Utilisateur u = db.Utilisateurs.FirstOrDefault(x => x.login.Equals(username));
                if (u == null)
                    return null;
                else
                {
                    var membershipUser = new CustomMembershipUser(u);
                    //store in cache
                    HttpRuntime.Cache.Insert(cacheKey, membershipUser, null, DateTime.Now.AddMinutes(_cacheTimeoutInMinutes), Cache.NoSlidingExpiration);

                    return membershipUser;
                }
            }
        }