Ejemplo n.º 1
0
 public override string[] GetRolesForUser(string username)
 {
     using (DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter())
     {
         var user = UserEntity.FetchUser(adapter, username);
         return(new string[] { user.Role.Name });
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Read and write data access adapter
        /// </summary>
        /// <param name="userName">Used for audit info log.</param>
        public static DataAccessAdapterBase GetDataAccessAdapter(string userName)
        {
            CoolJ.SqlServer.DatabaseSpecific.DataAccessAdapter adapter = new CoolJ.SqlServer.DatabaseSpecific.DataAccessAdapter();

            UserEntity user = UserEntity.FetchUser(adapter, userName);

            if (user != null)
            {
                ((INsDataAccessAdapter)adapter).UserId = user.UserId;
            }

            return(adapter);
        }
        public override bool ValidateUser(string name, string password)
        {
            using (DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter())
            {
                UserEntity user = UserEntity.FetchUser(adapter, name);

                if (user == null ||
                    !Common.Cryptography.ValidatePassword(user.Password, password))
                {
                    return(false);
                }
            }

            return(true);
        }
        public override MembershipUser GetUser(string name, bool userIsOnline)
        {
            UserEntity user;

            using (DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter())
            {
                user = UserEntity.FetchUser(adapter, name);
            }

            return(new MembershipUser(this.Name,
                                      user.Username,
                                      user.UserId,
                                      string.Empty,
                                      string.Empty,
                                      string.Empty,
                                      true,
                                      false,
                                      DateTime.Now,
                                      DateTime.Now,
                                      DateTime.Now,
                                      DateTime.Now,
                                      DateTime.Now));
        }