Exemplo n.º 1
0
        public virtual ActionResult ResetAll()
        {
            if (System.Configuration.ConfigurationManager.AppSettings["AllowResetOrElevate"] != "true")
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            new AccountController().FormsAuth.SignOut(); // otherwise auth cookie will persist if we're logged in and then we won't have a userID but Request.IsAuthenticated will still be true.

            var db = Current.DB;

            db.Matches.DeleteAllOnSubmit(db.Matches); // clear all rows
            db.SubmitChanges();

            db.Responses.DeleteAllOnSubmit(db.Responses);
            db.SubmitChanges();

            db.UserOpenIds.DeleteAllOnSubmit(db.UserOpenIds);
            db.SubmitChanges();

            foreach (string role in Roles.GetAllRoles())
            {
                var users = Roles.GetUsersInRole(role);
                if (users != null && users.Any())
                {
                    Roles.RemoveUsersFromRole(Roles.GetUsersInRole(role), role);
                }
                Roles.DeleteRole(role);
            }

            foreach (MembershipUser u in Membership.GetAllUsers())
            {
                Membership.DeleteUser(u.UserName, true);
            }

            Roles.CreateRole("Administrator");

            return(Content("Done"));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var membershipUsers = Membership.GetAllUsers();
            var users           = new List <UserViewModel>(membershipUsers.Count);

            foreach (MembershipUser mu in membershipUsers)
            {
                Guid userID = (Guid)mu.ProviderUserKey;
                var  user   = db.Users.Find(userID);
                if (user == null)
                {
                    user    = new User();
                    user.ID = userID;
                }
                var userModel = new UserViewModel(user);
                userModel.UserName = mu.UserName;
                userModel.Email    = mu.Email;
                users.Add(userModel);
            }

            return(View(users));
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //
            //if this is a fresh install, create a new user.
            //
            int nrUsers;

            Membership.GetAllUsers(0, 1, out nrUsers);
            if (nrUsers == 0)
            {
                LoginMultiView.SetActiveView(CreateUserView);
                //Membership.CreateUser("admin", "admin", ");
            }

            //Page.Form.DefaultFocus = Login1.FindControl("UserName").UniqueID;
            //Page.SetFocus(Login1);
            Login1.Focus();

            //ID="LoginButton" if button is a Button.
            //ID="LoginLinkButton" if button is a link LinkButton.
            Page.Form.DefaultButton = Login1.FindControl("LoginButton").UniqueID;
        }
Exemplo n.º 4
0
        public static List <MembershipUser> GetUserList(int idEmpresa)
        {
            try
            {
                var users = Membership.GetAllUsers();
                using (var db = new NtLinkLocalServiceEntities())
                {
                    var us_emp        = db.usuarios_empresas.Where(p => p.IdEmpresa == idEmpresa).ToList();
                    var res           = users.Cast <MembershipUser>().ToList();
                    var listaUsuarios = from re in res
                                        join u in us_emp on re.ProviderUserKey.ToString() equals u.UserId
                                        select re;

                    return(listaUsuarios.ToList());
                }
            }
            catch (Exception eee)
            {
                Logger.Error(eee);
                return(null);
            }
        }
Exemplo n.º 5
0
        public JsonResult GetUsersRoleJson(String roleName)
        {
            AuthenticationsAndAuthorizationsOperations anaOps = new AuthenticationsAndAuthorizationsOperations();
            List <ListUsersViewModel> usersInRoleList         = new List <ListUsersViewModel>();
            List <ListUsersViewModel> usersNOTInRoleList      = new List <ListUsersViewModel>();

            if (!String.IsNullOrEmpty(roleName) && Roles.RoleExists(roleName))
            {
                String[] inRoleUsers = Roles.GetUsersInRole(roleName);
                MembershipUserCollection allUsers = Membership.GetAllUsers();
                foreach (MembershipUser user in allUsers)
                {
                    ListUsersViewModel listUsersViewModel = new ListUsersViewModel();
                    if (inRoleUsers.Contains(user.UserName))
                    {
                        listUsersViewModel.Email            = user.Email;
                        listUsersViewModel.ExpiredDate      = (anaOps.GetExpiryDate(user.UserName)).ToString(dateTimeFormat);
                        listUsersViewModel.LastActivityDate = (user.LastActivityDate).ToString(dateTimeFormat);
                        listUsersViewModel.MobileAlias      = anaOps.GetMobileAliasByUserName(user.UserName);
                        listUsersViewModel.UserName         = user.UserName;
                        listUsersViewModel.ThisRoleOwner    = anaOps.IsRoleOwner(user.UserName, roleName);
                        usersInRoleList.Add(listUsersViewModel);
                    }
                    if (!inRoleUsers.Contains(user.UserName))
                    {
                        listUsersViewModel.Email            = user.Email;
                        listUsersViewModel.ExpiredDate      = (anaOps.GetExpiryDate(user.UserName)).ToString(dateTimeFormat);
                        listUsersViewModel.LastActivityDate = (user.LastActivityDate).ToString(dateTimeFormat);
                        listUsersViewModel.MobileAlias      = anaOps.GetMobileAliasByUserName(user.UserName);
                        listUsersViewModel.UserName         = user.UserName;
                        usersNOTInRoleList.Add(listUsersViewModel);
                    }
                }
            }
            return(Json(new {
                TotalInRole = usersInRoleList.Count, DataInRole = usersInRoleList,
                TotalNotInRole = usersNOTInRoleList.Count, DataNotInRole = usersNOTInRoleList
            }));
        }
Exemplo n.º 6
0
    protected void FVUserInfoShow_DataBound1(object sender, EventArgs e)
    {
        if (FVUserInfoShow.DataItemCount == 0)
        {
            Response.Redirect("~/404.aspx");
        }
        string qstr = Request.QueryString["user"];
        MembershipUserCollection users = Membership.GetAllUsers();

        foreach (MembershipUser user in users)
        {
            if (user.UserName == qstr)
            {
                if (user.IsOnline)
                {
                    Label lblUserOnline = FVUserInfoShow.FindControl("lblUserOnl") as Label;
                    lblUserOnline.ForeColor = Color.Green;
                    lblUserOnline.Text      = "(Online)";
                }
            }
        }
    }
Exemplo n.º 7
0
 public ActionResult ValidatePost(ValidateAccountModel model)
 {
     if (ModelState.IsValid)
     {
         MembershipUser       user  = Membership.GetUser(model.LoginName);
         IEnumerable <string> count = from MembershipUser u in Membership.GetAllUsers()
                                      where model.Nickname.Equals(u.Comment)
                                      select u.Comment;
         if (count.Count() == 0)
         {
             HttpCookie cookie = Request.Cookies[".SPOTICHELASANONYMOUS"];
             if (cookie == null)
             {
                 ModelState.AddModelError("", "Validation code expired! Please Register again. Also allow cookies in order to complete the regristration");
             }
             //Note: Due to the challenge code being kept in a cookie, they must be activated in the browser. Embebing into Url would be an option but a security risk
             FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
             string challenge = ticket.UserData;
             if (model.Challenge.Equals(challenge))
             {
                 user.IsApproved = true;
                 user.Comment    = model.Nickname;
                 Roles.AddUserToRole(user.UserName, "User");
                 Membership.UpdateUser(user);
                 FormsAuthentication.SetAuthCookie(user.UserName, true /* createPersistentCookie */);
                 return(RedirectToAction("UserCP"));
             }
             else
             {
                 ModelState.AddModelError("challenge", "Invalid Challenge Code!");
             }
         }
         else
         {
             ModelState.AddModelError("nickname", "Public name already taken!");
         }
     }
     return(View("Validate"));
 }
Exemplo n.º 8
0
        public ViewResult QualifyForCommissioning()
        {
            var minCoresNeeded     = 0; //db.CommissioningRequirementse.Find(1).CoreCoursesRequired;
            var minElectivesNeeded = 0; //db.CommissioningRequirementse.Find(1).ElectiveCoursesRequired;

            IEnumerable <MembershipUser> users          = Membership.GetAllUsers().Cast <MembershipUser>();
            ICollection <Student>        qualifiedUsers = new List <Student>();

            foreach (var user in users)
            {
                var thisStudent = db.Students.FirstOrDefault(o => o.UserName == user.UserName);
                Debug.Write(user.UserName);
                Debug.Write(thisStudent.UserName);
                var coresPassed     = TotalCoresPassed(thisStudent);
                var electivesPassed = TotalElectivesPassed(thisStudent);
                if (coresPassed >= minCoresNeeded && electivesPassed >= minElectivesNeeded)
                {
                    qualifiedUsers.Add(thisStudent);
                }
            }
            return(View(qualifiedUsers));
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable userTable = new DataTable();
                userTable.Columns.Add("UserName", typeof(string));
                userTable.Columns.Add("FirstName", typeof(string));
                userTable.Columns.Add("LastName", typeof(string));
                userTable.Columns.Add("Email", typeof(string));

                MembershipUserCollection users = Membership.GetAllUsers();

                foreach (MembershipUser user in users)
                {
                    userTable.Rows.Add(user.UserName, Profile.GetProfile(user.UserName).FirstName, Profile.GetProfile(user.UserName).LastName, user.Email);
                }

                // Bind users to Grid.
                Users_ListBox.DataSource = userTable;
                Users_ListBox.DataBind();
            }
        }
Exemplo n.º 10
0
        public ActionResult ListUsers()
        {
            var users = Membership.GetAllUsers();
            List <SetRoleModel> roleModels = new List <SetRoleModel>();
            SetRoleModel        roleModel;

            foreach (MembershipUser user in users)
            {
                roleModel          = new SetRoleModel();
                roleModel.UserName = user.UserName;
                if (Roles.IsUserInRole("Admin"))
                {
                    roleModel.IsAdmin = true;
                }
                if (Roles.IsUserInRole("Envirolytic"))
                {
                    roleModel.IsEnvirolytic = true;
                }
                roleModels.Add(roleModel);
            }
            return(View(roleModels));
        }
Exemplo n.º 11
0
        private void SendEmail(Order order)
        {
            //var client = new RestClient();
            //client.BaseUrl = "https://api.mailgun.net/v2";
            //client.Authenticator = new HttpBasicAuthenticator("api", "key-46@qffnszp0xztzms0");
            //var request = new RestRequest();
            //request.AddParameter("domain", "pigbob.mailgun.org", ParameterType.UrlSegment);
            //request.Resource = "{domain}/messages";
            //request.AddParameter("from", "Pigbob <*****@*****.**>");
            //request.AddParameter("subject", "New Pig Order!");
            //var messageBody = "<html>Hello, a fellow PigBobber has created a new Pig Run for <strong>" + order.OrderDate.ToLongDateString() + "</strong><br/><br/>" +
            //    "Please click <a href=\"http://pigbob.azurewebsites.net/Sandwiches/Index/" + order.OrderID + "\">here</a> to place your order.";
            //request.AddParameter("html", messageBody);
            //request.Method = Method.POST;

            //request.AddParameter("to", "*****@*****.**");

            //var result = client.Execute(request);



            MailMessage message = new MailMessage();

            message.From       = new MailAddress("*****@*****.**");
            message.Subject    = "New Pig Order!";
            message.IsBodyHtml = true;
            message.Body       = "Hello, a fellow PigBobber has created a new Pig Run for <strong>" + order.OrderDate.ToLongDateString() + "</strong><br/><br/>" +
                                 "Please click <a href=\"http://pigbob.azurewebsites.net/Sandwiches/Index/" + order.OrderID + "\">here</a> to place your order.";
            var members = Membership.GetAllUsers();

            foreach (MembershipUser member in members)
            {
                message.To.Add(member.Email);
            }
            //message.To.Add("*****@*****.**");
            SmtpClient smtp = new SmtpClient();

            smtp.Send(message);
        }
Exemplo n.º 12
0
    public static string GetAllUserNameList()
    {
        MembershipUserCollection arrUser = Membership.GetAllUsers();

        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        if (0 != arrUser.Count)
        {
            sb.Append("<select id='selectAllUser' onchange='getRoleByUser(this.value)'>");
            foreach (MembershipUser arr in arrUser)
            {
                sb.Append("<option value='" + arr.UserName + "'>");
                sb.Append(arr.UserName);
                sb.Append("</option>");
            }
            sb.Append("</select>");
            return(sb.ToString());
        }
        else
        {
            return(sb.Append("暂无用户").ToString());
        }
    }
Exemplo n.º 13
0
        private void BindAllUsers(bool reloadAllUsers)
        {
            MembershipUserCollection allUsers = null;

            if (reloadAllUsers)
            {
                allUsers = Membership.GetAllUsers();
            }

            string searchText = "";

            if (!string.IsNullOrEmpty(UsersGridView.Attributes["SearchText"]))
            {
                searchText = UsersGridView.Attributes["SearchText"];
            }
            bool searchByEmail = false;

            if (!string.IsNullOrEmpty(UsersGridView.Attributes["SearchByEmail"]))
            {
                searchByEmail = bool.Parse(UsersGridView.Attributes["SearchByEmail"]);
            }
            if (searchText.Length > 0)
            {
                if (searchByEmail)
                {
                    allUsers = Membership.FindUsersByEmail(searchText);
                }
                else
                {
                    allUsers = Membership.FindUsersByName(searchText);
                }
            }
            else
            {
                allUsers = allRegisteredUsers;
            }
            UsersGridView.DataSource = allUsers;
            UsersGridView.DataBind();
        }
Exemplo n.º 14
0
        internal void refreshDGV()
        {
            string str;

            this.dgvUsers.Rows.Clear();
            MembershipUserCollection allUsers = Membership.GetAllUsers();

            foreach (MembershipUser allUser in allUsers)
            {
                if (Roles.GetRolesForUser(allUser.UserName).Count <string>() > 0)
                {
                    str = Roles.GetRolesForUser(allUser.UserName).ElementAt <string>(0);
                    continue;
                }
                str = "";
                object[] userName = new object[2];
                userName[0] = allUser.UserName;
                userName[1] = str;
                object[] objArray = userName;
                this.dgvUsers.Rows.Add(objArray);
            }
        }
Exemplo n.º 15
0
        public string GetUserList(string appName, bool MappedApplication)
        {
            StringBuilder userXml = new StringBuilder();
            string        oldApp  = Membership.ApplicationName;

            try
            {
                if (MappedApplication)
                {
                    Membership.ApplicationName = GetMapping(appName);
                }
                else
                {
                    Membership.ApplicationName = appName;
                }

                userXml.Append("<users>");
                // get users for the given application
                MembershipUserCollection mbrColl = Membership.GetAllUsers();
                foreach (MembershipUser user in mbrColl)
                {
                    userXml.Append("<user>");
                    userXml.Append("<login>");
                    userXml.Append(user.UserName);
                    userXml.Append("</login>");
                    userXml.Append("<email>");
                    userXml.Append(user.Email);
                    userXml.Append("</email>");
                    userXml.Append("</user>");
                }
                userXml.Append("</users>");
            }
            finally
            {
                Membership.ApplicationName = oldApp;
            }
            return(userXml.ToString());
        }
Exemplo n.º 16
0
        /// <summary>
        /// Get a list of accounts that not exists in Role NONE
        /// </summary>
        /// <returns>A list of accounts</returns>
        public List <string> UsersNotInRoleNone()
        {
            try
            {
                MembershipUserCollection theCompleteUserList;
                theCompleteUserList = Membership.GetAllUsers();

                List <string> theAllUserList = new List <string>();
                foreach (MembershipUser user in theCompleteUserList)
                {
                    theAllUserList.Add(user.UserName);
                }

                List <string> theAllRolesList = new List <string>();
                theAllRolesList.AddRange(Roles.GetAllRoles());

                List <string> theUsersInSomeRoleList = new List <string>();
                foreach (string Role in theAllRolesList)
                {
                    List <string> TheRoleList = new List <string>();
                    TheRoleList.AddRange(Roles.GetUsersInRole(Role));
                    foreach (string User in TheRoleList)
                    {
                        if (!theUsersInSomeRoleList.Contains(User))
                        {
                            theUsersInSomeRoleList.Add(User);
                        }
                    }
                }

                return(theUsersInSomeRoleList);
            }
            catch (Exception q)
            {
                log.Error("An error was ocurred while creating the Account List", q);
                return(null);
            }
        }
Exemplo n.º 17
0
    private void BindAllUsers(bool reloadAllUsers)
    {
        MembershipUserCollection allUsers = null;

        if (reloadAllUsers)
        {
            allUsers = Membership.GetAllUsers();
        }
        string searchText = "";

        if (!string.IsNullOrEmpty(gvUsers.Attributes["SearchText"]))
        {
            searchText = gvUsers.Attributes["SearchText"];
        }
        bool searchByEmail = false;

        if (!string.IsNullOrEmpty(gvUsers.Attributes["SearchByEmail"]))
        {
            searchByEmail = bool.Parse(gvUsers.Attributes["SearchByEmail"]);
        }
        if (searchText.Length > 0)
        {
            if (searchByEmail)
            {
                allUsers = Membership.FindUsersByEmail(searchText);
            }
            else
            {
                allUsers = Membership.FindUsersByName(searchText.ToUpper(System.Globalization.CultureInfo.InvariantCulture));
            }
        }
        else
        {
            allUsers = allRegisteredUsers;
        }
        gvUsers.DataSource = allUsers;
        gvUsers.DataBind();
    }
Exemplo n.º 18
0
        public ActionResult Index(int?page)
        {
            int index = page.HasValue ? page.Value - 1 : 0;

            var listUserModel  = new List <UserModel>();
            var aspnetUserList = Membership.GetAllUsers();

            if (aspnetUserList != null || aspnetUserList.Count > 0)
            {
                foreach (MembershipUser aspnetUser in aspnetUserList)
                {
                    string loginUserName = AccountController.CurrentUser.UserName;

                    if (Roles.IsUserInRole(aspnetUser.UserName, RoleList.SuperAdmin))
                    {
                        continue;//không hiện SuperAdmin
                    }

                    if (loginUserName == aspnetUser.UserName)
                    {
                        continue;//Không hiện chính mình
                    }

                    if (loginUserName != "sa" &&
                        loginUserName != "admin" &&
                        Roles.IsUserInRole(RoleList.Admin) &&
                        Roles.IsUserInRole(aspnetUser.UserName, RoleList.Admin))
                    {
                        continue;//Không hiện những user là Admin cùng cấp
                    }

                    var userModel = GetUser(aspnetUser);
                    listUserModel.Add(userModel);
                }
            }

            return(View(listUserModel.OrderBy(m => m.Id).ToPagedList(index, PageSize)));
        }
Exemplo n.º 19
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>All users, sorted by username</returns>
        public IEnumerable <UserInfo> GetUsers()
        {
            lock (usersCacheLock)
            {
                UserInfo[] result = usersCache;

                bool expired = usersCacheCreation < DateTime.Now.AddMinutes(-CacheDuration);

                if (!expired && result != null)
                {
                    return(result);
                }

                if (expired)
                {
                    usersCacheCreation = DateTime.Now;
                }

                usersCache = Membership.GetAllUsers().OfType <MembershipUser>().OrderBy(u => u.UserName).Select(u => ToUserInfo(u, false, false)).ToArray();

                return(usersCache);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Gets the users not in role.
        /// </summary>
        /// <param name="roleName">Name of the role.</param>
        /// <returns></returns>
        public static List <UserDetails> GetUsersNotInRole(string roleName)
        {
            List <UserDetails> usersNotInRole = new List <UserDetails>();

            try
            {
                MembershipUserCollection users = Membership.GetAllUsers();
                foreach (MembershipUser user in users)
                {
                    if (!Roles.IsUserInRole(user.UserName, roleName))
                    {
                        UserDetails userDetail = new UserDetails(user, false);
                        usersNotInRole.Add(userDetail);
                    }
                }
            }
            catch (ArgumentNullException)
            {
                return(null);
            }
            usersNotInRole.Sort(new UniversalComparer <UserDetails>("UserName"));
            return(usersNotInRole);
        }
Exemplo n.º 21
0
    protected void ResetButton_Click(object sender, EventArgs e)
    {
        SiteDataManage.DeleteData();
        File.Delete(HttpContext.Current.Server.MapPath("~/Web.sitemap"));
        MembershipUserCollection collection = new MembershipUserCollection();

        collection = Membership.GetAllUsers();
        foreach (MembershipUser user in collection)
        {
            Membership.DeleteUser(user.ToString());
        }
        FormsAuthentication.SignOut();
        Membership.CreateUser("admin", "admin", "*****@*****.**");
        MembershipUser admin = Membership.GetUser("admin");

        admin.IsApproved = true;
        if (!Roles.IsUserInRole("admin", "administrators"))
        {
            Roles.AddUserToRole("admin", "administrators");
        }
        Membership.UpdateUser(admin);
        Response.Redirect("~/default.aspx");
    }
Exemplo n.º 22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblMsg.Visible = false;
        if (!IsPostBack)
        {
            MembershipUserCollection allUsers = Membership.GetAllUsers();
            MembershipUserCollection allUsersWithoutCurrent = Membership.GetAllUsers();
            allUsersWithoutCurrent.Remove(User.Identity.Name);

            grdvwManageUsers.DataSource = allUsers;
            grdvwManageUsers.DataBind();

            ddlChangePasswordUser.DataSource = allUsers;
            ddlChangePasswordUser.DataBind();

            ddlDeleteUser.DataSource = allUsersWithoutCurrent;
            ddlDeleteUser.DataBind();

            grdvwManageUsers.FooterRow.Cells[0].ColumnSpan = 3;
            grdvwManageUsers.FooterRow.Cells.RemoveAt(1);
            grdvwManageUsers.FooterRow.Cells.RemoveAt(1);
        }
    }
Exemplo n.º 23
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"></see> interface.
        /// </summary>
        /// <param name="context">
        /// An <see cref="T:System.Web.HttpContext"></see> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.
        /// </param>
        public void ProcessRequest(HttpContext context)
        {
            // attempt to grab the username from the URL
            // where URL = www.mysite.com/foaf_admin.axd
            // username = '******'
            var filename = context.Request.Url.ToString();
            var name     =
                filename.Substring(filename.LastIndexOf("/") + 1).Replace(".axd", string.Empty).Replace(
                    "foaf_", string.Empty).Replace("foaf", string.Empty);

            // if no name is specificied, then grab the first user from Membership
            if (name == string.Empty)
            {
                foreach (MembershipUser user in Membership.GetAllUsers())
                {
                    name = user.UserName;
                    break;
                }
            }

            context.Response.ContentType = "application/rdf+xml";
            this.WriteFoaf(context, name);
        }
        public override void Update()
        {
            var employee = Membership.GetAllUsers().Cast <MembershipUser>().Where(c => c.ProviderUserKey.ToString() == SelectedItemGuid.ToString()).FirstOrDefault();

            if (employee == null)
            {
                return;
            }

            ProfileBase curProfile = ProfileBase.Create(employee.UserName);
            string      resimadi   = curProfile.GetPropertyValue("ResimAdi").ToString();

            EmployeeImage.ImageUrl = "../../Images/UploadPersonel/" + resimadi;

            DetailsHeaderHeadLine.HeaderText  = string.Format("{0} {1}", curProfile.GetPropertyValue("Ismi").ToString(), curProfile.GetPropertyValue("Soyismi").ToString());
            DetailsHeaderHeadLine.ContentText = employee.UserName;
            DetailsAddressText.InnerHtml      = curProfile.GetPropertyValue("BayiKodu").ToString();
            DetailsPhoneText.InnerHtml        = curProfile.GetPropertyValue("CepNumarasi").ToString();
            DetailsEmailText.InnerHtml        = employee.Email;

            ////    EditImage.JSProperties["cpEmployeeID"] = list.First().ID;
            ////    DetailsHeaderHeadLine.NavigateUrl = string.Format("javascript:ShowEmployeeEditForm('{0}')", list.First().ID);
        }
Exemplo n.º 25
0
        public bool IsValidUserName(string username)
        {
            bool isvalid = false;


            if (username != "" && username.Length >= Membership.MinRequiredPasswordLength)
            {
                using (JobRepoDataContext context = new JobRepoDataContext())
                {
                    var query = from MembershipUser user in Membership.GetAllUsers()
                                //Notice that you  cannot user Lambda where .Where ( e => e. ....)
                                //instead , you need to use by LINQ Where operator: where user.....
                                where user.UserName.ToUpper().Equals(username.ToUpper())
                                select user;


                    //IQueryable is not serializable so if we need to return the result ,
                    //it should be returned as list :  query.ToList();
                    isvalid = (query.Count() == 0);
                }
            }
            return(isvalid);
        }
Exemplo n.º 26
0
        public ActionResult AutoCompleteUsers(string term)
        {
            MembershipUserCollection users    = Membership.GetAllUsers();
            List <string>            response = new List <string>();

            foreach (MembershipUser user in users)
            {
                if (user.UserName.ToUpper().Contains(term.ToUpper()))
                {
                    response.Add(user.UserName);
                }
            }


            var roles = this.roleService.GetAllRoles();

            foreach (string role in roles)
            {
                response.Add(role);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 27
0
        private void ShowUserList()
        {
            try
            {
                //Show system user as normal
                MembershipUserCollection list  = new MembershipUserCollection();
                string userNameFilter          = userNameTextBox.Text.Trim().ToUpper();
                MembershipUserCollection users = Membership.GetAllUsers();

                try
                {
                    foreach (MembershipUser user in users)
                    {
                        if (string.IsNullOrEmpty(userNameFilter))
                        {
                            list.Add(user);
                        }
                        else if (user.UserName.ToUpper().Contains(userNameFilter))
                        {
                            list.Add(user);
                        }
                    }
                }
                catch { }

                systemUsersListView.DataSource = list;
                systemUsersListView.DataBind();
                //DataBindGridView(ConvertToDataTable(list));
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OKErrors",
                                                    "Main.setMasterMessage('No record found!','');", true);
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "CloseLoading",
                                                    "Dialog.hideLoader();", true);
            }
        }
Exemplo n.º 28
0
 public DataTable findAllUsers(out int outPageCount)
 {
     try
     {
         MembershipUserCollection myUsers = Membership.GetAllUsers(PageNumber - 1, RecordsPerPage, out RecordCount);
         PageCount = RecordCount / RecordsPerPage;
         if (RecordCount % RecordsPerPage > 0)
         {
             PageCount++;
         }
         outPageCount = PageCount;
         //load data
         if (RecordCount > 0)
         {
             int iPos = (PageNumber - 1) * RecordsPerPage + 1;
             foreach (MembershipUser user in myUsers)
             {
                 DataRow row;
                 row                     = Data.NewRow();
                 row["UserName"]         = user.UserName;
                 row["Email"]            = user.Email;
                 row["Comment"]          = user.Comment;
                 row["IsApproved"]       = user.IsApproved;
                 row["IsLockedOut"]      = user.IsLockedOut;
                 row["CreationDate"]     = user.CreationDate.ToShortDateString();
                 row["LastActivityDate"] = user.LastActivityDate.ToShortDateString();
                 row["IsOnline"]         = user.IsOnline;
                 Data.Rows.Add(row);
             }
         }
         return(Data);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 29
0
        public ActionResult Index()
        {
            MembershipUser passwordChangedUser = null;
            var            model = new AdminModel();

            foreach (MembershipUser user in Membership.GetAllUsers())
            {
                var roles = Roles.GetRolesForUser(user.UserName);

                model.UserModels.Add(new UserModel
                {
                    UserName = user.UserName,
                    Roles    = roles.ToList()
                });
            }

            var reports = _repository.GetReports();

            foreach (var report in reports)
            {
                var latestStats = report.Latest.Statistics;

                if (latestStats.IsEmpty == false)
                {
                    model.ReportModel.Add(new ReportViewModel
                    {
                        Name = report.Id
                    });
                }
            }

            if (passwordChangedUser != null)
            {
                model.NewPassword = passwordChangedUser.GetPassword();
            }
            return(View(model));
        }
Exemplo n.º 30
0
        public ActionResult FeatureAssignment()
        {
            FeatureAssignmentModel fam = new FeatureAssignmentModel();
            AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations();

            fam.accessProfile = aNaOps.GetAllFeatureAccessProfileModel();

            List <System.Web.Mvc.SelectListItem> DropdownUser = new List <SelectListItem>();

            foreach (MembershipUser user in Membership.GetAllUsers())
            {
                DropdownUser.Add(new SelectListItem {
                    Text = user.UserName, Value = user.UserName
                });
            }
            fam.DropdownUser = DropdownUser;
            List <System.Web.Mvc.SelectListItem> DropdownRole = new List <SelectListItem>();

            foreach (String role in Roles.GetAllRoles())
            {
                DropdownRole.Add(new SelectListItem {
                    Text = role, Value = role
                });
            }
            fam.DropdownRole = DropdownRole;
            List <System.Web.Mvc.SelectListItem> DropdownFeature = new List <SelectListItem>();

            foreach (FeatureProfile fp in aNaOps.GetALLRegisteredFeatures())
            {
                DropdownFeature.Add(new SelectListItem {
                    Text = fp.FeatureName, Value = fp.FeatureName
                });
            }
            fam.DropdownFeature = DropdownFeature;

            return(View(fam));
        }