protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.Security.MembershipUser logUser        = System.Web.Security.Membership.GetUser(User.Identity.Name);
            CapaNegocio.clsOrientador          usuario        = new CapaNegocio.clsOrientador();
            CapaDatos.clsDOrientador           objDatosPerfil = new CapaDatos.clsDOrientador();
            usuario       = objDatosPerfil.D_consultarOrientador(logUser.UserName.ToString());
            Session["id"] = usuario.IDOrientador1;
            if (chbTrabaja.Checked == true)
            {
                txtTiempoTrabajo.Visible             = true;
                RegularExpressionValidator12.Visible = true;
                lblTrabaja.Visible = true;
            }
            else
            {
                txtTiempoTrabajo.Visible             = false;
                RegularExpressionValidator12.Visible = false;
                lblTrabaja.Visible = false;
            }

            if (bandera == 1)
            {
                txtTelefono0.Visible = true;
            }
            else if (bandera == 2)
            {
                txtTelefono1.Visible = true;
            }

            if (!IsPostBack)
            {
                cargarDDLs();
                bandera = 0;
            }
        }
        /// <summary>
        /// Provides a list of users to whom the calendar has been shared.
        /// </summary>
        /// <remarks>
        /// http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk/doc/Extensions/caldav-sharing.txt
        /// (Section 5.2.2)
        public async Task <IEnumerable <SharingInvite> > GetInviteAsync()
        {
            IList <SharingInvite> invites = new List <SharingInvite>();

            foreach (DataRow rowAccess in rowsAccess)
            {
                if (rowAccess.Field <bool>("Owner"))
                {
                    continue;
                }

                string userId = rowAccess.Field <string>("UserId");
                System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(userId);

                SharingInvite ace = new SharingInvite
                {
                    Address      = string.Format("email:{0}", user.Email)
                    , Access     = rowAccess.Field <bool>("Write") ? SharingInviteAccess.ReadWrite : SharingInviteAccess.Read
                    , CommonName = user.UserName
                    , Status     = SharingInviteStatus.Accepted
                };
            }

            return(invites);
        }
        public void bindMember(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                if (cms.businesslogic.member.Member.InUmbracoMemberMode())
                {
                    cms.businesslogic.member.Member mem = (cms.businesslogic.member.Member)e.Item.DataItem;
                    Literal _name   = (Literal)e.Item.FindControl("lt_name");
                    Literal _email  = (Literal)e.Item.FindControl("lt_email");
                    Literal _login  = (Literal)e.Item.FindControl("lt_login");
                    Button  _button = (Button)e.Item.FindControl("bt_delete");

                    _name.Text  = "<a href='editMember.aspx?id=" + mem.Id.ToString() + "'>" + mem.Text + "</a>";
                    _login.Text = mem.LoginName;
                    _email.Text = mem.Email;

                    _button.CommandArgument = mem.Id.ToString();
                    _button.OnClientClick   = "return confirm(\"" + ui.Text("confirmdelete") + "'" + mem.Text + "' ?\")";
                    _button.Text            = ui.Text("delete");
                }
                else
                {
                    System.Web.Security.MembershipUser mem = (System.Web.Security.MembershipUser)e.Item.DataItem;
                    Literal _name   = (Literal)e.Item.FindControl("lt_name");
                    Literal _email  = (Literal)e.Item.FindControl("lt_email");
                    Literal _login  = (Literal)e.Item.FindControl("lt_login");
                    Button  _button = (Button)e.Item.FindControl("bt_delete");

                    _name.Text      = "<a href='editMember.aspx?id=" + mem.UserName + "'>" + mem.UserName + "</a>";
                    _login.Text     = mem.UserName;
                    _email.Text     = mem.Email;
                    _button.Visible = false;
                }
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.Security.MembershipUser logUser        = System.Web.Security.Membership.GetUser(User.Identity.Name);
            CapaNegocio.clsOrientador          usuario        = new CapaNegocio.clsOrientador();
            CapaDatos.clsDOrientador           objDatosPerfil = new CapaDatos.clsDOrientador();
            usuario       = objDatosPerfil.D_consultarOrientador(logUser.UserName.ToString());
            Session["id"] = usuario.IDOrientador1;
            if (!IsPostBack)
            {
                for (int i = 7; i >= 0; i--)
                {
                    ListItem li = new ListItem();

                    li.Text  = DateTime.Today.AddDays(-i).ToString("yyyy/MM/dd");
                    li.Value = DateTime.Today.AddDays(-i).ToString("yyyy/MM/dd");
                    ddlFecha.Items.Add(li);
                }
            }
            if (!IsPostBack)
            {
                int idOrientador = (int)Session["id"];
                try
                {
                    cargarLineaAccion();
                    cargarProceso(int.Parse(ddlLineaAccion.SelectedValue));
                    cargarPeriodo(idOrientador, int.Parse(ddlProceso.SelectedValue), int.Parse(ddlLineaAccion.SelectedValue));
                }
                catch {
                }
            }
        }
        /// <summary>
        /// Update the user.
        /// </summary>
        /// <param name="user">The membership user.</param>
        public void UpdateUser(System.Web.Security.MembershipUser user)
        {
            // Get the user data.
            Nequeo.DataAccess.CloudInteraction.Data.User userData = GetSpecificUser(user.UserName);

            // Update the user.
            if (user != null)
            {
                new Nequeo.DataAccess.CloudInteraction.Data.Extension.User().
                Update.UpdateItemPredicate(
                    new Data.User()
                {
                    Password                = userData.Password,
                    PasswordAnswer          = userData.PasswordAnswer,
                    Email                   = user.Email,
                    LastLoginDate           = user.LastLoginDate,
                    LoggedIn                = user.IsOnline,
                    UserSuspended           = user.IsLockedOut,
                    LastActivityDate        = user.LastActivityDate,
                    PasswordQuestion        = user.PasswordQuestion,
                    LastPasswordChangedDate = user.LastPasswordChangedDate,
                    UserSuspendedDate       = user.LastLockoutDate,
                    Comments                = user.Comment
                }, u =>
                    (u.Username == user.UserName) &&
                    (u.ApplicationName == ApplicationName)
                    );
            }
        }
        protected override void SetupDependencies()
        {
            base.SetupDependencies();
            MembershipUser expectedUser = CreateTestMembershipUser(userName);

            GetDependency <IMembershipManager>().GetUser(userName).Returns(expectedUser);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.Security.MembershipUser logUser        = System.Web.Security.Membership.GetUser(User.Identity.Name);
            CapaNegocio.clsOrientador          usuario        = new CapaNegocio.clsOrientador();
            CapaDatos.clsDOrientador           objDatosPerfil = new CapaDatos.clsDOrientador();
            usuario       = objDatosPerfil.D_consultarOrientador(logUser.UserName.ToString());
            Session["id"] = usuario.IDOrientador1;

            int         idOrientador = (int)Session["id"];
            clsDProceso objProceso   = new clsDProceso();

            if (!Page.IsPostBack)
            {
                try
                {
                    DropDownList1.DataSource     = objProceso.D_consultarProcesoPorOrientador(idOrientador);
                    DropDownList1.DataTextField  = "Nombre";
                    DropDownList1.DataValueField = "IdProceso";
                    DropDownList1.DataBind();
                }
                catch
                {
                }
            }
        }
Exemple #8
0
        public void MigrateUser(System.Web.Security.MembershipUser user, string password)
        {
            //@UserName					nvarchar(256),
            //@Password					nvarchar(256),
            //@Email						nvarchar(256),
            //@PasswordQuestion			nvarchar(256),
            //@IsApproved					bit,
            //@IsLockedOut				bit,
            //@DateCreated				datetime,
            //@DateLastPasswordChanged	datetime,
            //@DateLastLockout			datetime,
            //@DateLastLogin				datetime
            string pass = null;

            if (!String.IsNullOrEmpty(password))
            {
                pass = Cryptography.Encrypt(password, SecurityManager.EncryptKey, SecurityManager.EncryptIV, EncryptionAlgorithm.Rijndael);
            }
            SqlHelper.ExecuteNonQuery(_connectionString, "dbo.lg_Users_MigrateUser",
                                      SqlHelper.CreateInputParam("@UserName", SqlDbType.NVarChar, user.UserName),
                                      SqlHelper.CreateInputParam("@Password", SqlDbType.NVarChar, pass),
                                      SqlHelper.CreateInputParam("@Email", SqlDbType.NVarChar, user.Email),
                                      SqlHelper.CreateInputParam("@PasswordQuestion", SqlDbType.NVarChar, user.PasswordQuestion),
                                      SqlHelper.CreateInputParam("@IsApproved", SqlDbType.Bit, user.IsApproved),
                                      SqlHelper.CreateInputParam("@IsLockedOut", SqlDbType.Bit, user.IsLockedOut),
                                      SqlHelper.CreateInputParam("@DateCreated", SqlDbType.DateTime, user.CreationDate),
                                      SqlHelper.CreateInputParam("@DateLastPasswordChanged", SqlDbType.DateTime, user.LastPasswordChangedDate),
                                      SqlHelper.CreateInputParam("@DateLastLockout", SqlDbType.DateTime, user.LastLockoutDate),
                                      SqlHelper.CreateInputParam("@DateLastLogin", SqlDbType.DateTime, user.LastLoginDate));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.Security.MembershipUser logUser        = System.Web.Security.Membership.GetUser(User.Identity.Name);
            CapaNegocio.clsOrientador          usuario        = new CapaNegocio.clsOrientador();
            CapaDatos.clsDOrientador           objDatosPerfil = new CapaDatos.clsDOrientador();
            usuario       = objDatosPerfil.D_consultarOrientador(logUser.UserName.ToString());
            Session["id"] = usuario.IDOrientador1;

            int idOrientador = (int)Session["id"];

            try
            {
                if (!IsPostBack)
                {
                    cargarProceso();
                    for (int i = 2016; i <= int.Parse(DateTime.Now.ToString("yyyy")); i++)
                    {
                        ListItem li = new ListItem();
                        li.Text  = i.ToString();
                        li.Value = i.ToString();
                        ddlAnio.Items.Add(li);
                    }
                    cargarPersonas();
                }
            }
            catch { }
        }
        protected virtual bool UpdatePassword(string oldPassword, string newPassword, ref string message)
        {
            //get auth helper
            AuthenticationHelper authHelper = new AuthenticationHelper(Sitecore.Security.Authentication.AuthenticationManager.Provider);

            try {
                //check to see if the existing password is correct
                if (!authHelper.ValidateUser(Sitecore.Context.User.Name, oldPassword))
                {
                    //throw new System.Security.Authentication.AuthenticationException("Incorrect password.");
                    message = FormTextUtility.Provider.GetTextByKey("/EditAccount/OldPasswordIsIncorrect");
                }
                else
                {
                    //get the current user
                    System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(Sitecore.Context.User.Name);
                    if (user.ChangePassword(oldPassword, newPassword))
                    {
                        message = FormTextUtility.Provider.GetTextByKey("/EditAccount/PasswordHasBeenChanged");
                        return(true);
                    }
                    else
                    {
                        //throw new System.Security.Authentication.AuthenticationException("Unable to change password");
                        message = FormTextUtility.Provider.GetTextByKey("/EditAccount/UnableToChangePassword");
                    }
                }
            } catch (System.Security.Authentication.AuthenticationException) {
                message = FormTextUtility.Provider.GetTextByKey("/EditAccount/AuthenticationError");
            }
            return(false);
        }
Exemple #11
0
        public void ValidateKey_Click(object sender, System.EventArgs e)
        {
            DataTable dt      = YAF.Classes.Data.DB.checkemail_update(key.Text);
            DataRow   row     = dt.Rows [0];
            string    dbEmail = row ["Email"].ToString();

            bool keyVerified = (row["ProviderUserKey"] == DBNull.Value) ? false : true;

            approved.Visible = keyVerified;
            error.Visible    = !keyVerified;

            if (keyVerified)
            {
                // approve and update e-mail in the membership as well...
                System.Web.Security.MembershipUser user = UserMembershipHelper.GetMembershipUserByKey(row ["ProviderUserKey"]);
                if (!user.IsApproved)
                {
                    user.IsApproved = true;
                }
                // update the email if anything was returned...
                if (user.Email != dbEmail && dbEmail != "")
                {
                    user.Email = dbEmail;
                }
                // tell the provider to update...
                PageContext.CurrentMembership.UpdateUser(user);

                // now redirect to login...
                PageContext.LoadMessage.AddSession(GetText("EMAIL_VERIFIED"));

                YafBuildLink.Redirect(ForumPages.login);
            }
        }
Exemple #12
0
        protected virtual string AssignPendingAppsCallback(Dictionary <string, object> paraemeters)
        {
            string appName = paraemeters["@appName"].ToString();

            Durados.Web.Mvc.Map map = Durados.Web.Mvc.Maps.Instance.GetMap(appName);

            string username = paraemeters["@newUser"].ToString();

            System.Web.Security.MembershipUser user = map.GetMembershipProvider().GetUser(username, true);
            if (user != null)
            {
                if (!user.IsApproved && Durados.Web.Mvc.Maps.MultiTenancy)
                {
                    user.IsApproved = true;
                    System.Web.Security.Membership.UpdateUser(user);
                }
            }

            //string appName = paraemeters["@appName"].ToString();
            //Durados.Web.Mvc.Map map = Durados.Web.Mvc.Maps.Instance.GetMap(appName);
            //if (!map.Database.BackandSSO)
            //{
            //    Durados.Web.Mvc.UI.Helpers.AccountService.UpdateIsApproved(username, true, map);
            //}

            return("success");
        }
Exemple #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     System.Web.Security.MembershipUser logUser        = System.Web.Security.Membership.GetUser(User.Identity.Name);
     CapaNegocio.clsOrientador          usuario        = new CapaNegocio.clsOrientador();
     CapaDatos.clsDOrientador           objDatosPerfil = new CapaDatos.clsDOrientador();
     usuario       = objDatosPerfil.D_consultarOrientador(logUser.UserName.ToString());
     Session["id"] = usuario.IDOrientador1;
 }
Exemple #14
0
 public override bool UnlockUser(string userName)
 {
     System.Web.Security.MembershipUser user = this.GetMembershipUser(userName);
     if (user != null)
     {
         this.UpdateUserInternal(user, null, null, user.PasswordQuestion, false);
     }
     return(false);
 }
Exemple #15
0
 public override string GetUserNameByEmail(string email)
 {
     System.Web.Security.MembershipUser user = this.GetMembershipUserByEmail(email);
     if (user != null)
     {
         return(user.UserName);
     }
     return(String.Empty);
 }
Exemple #16
0
        /// <summary>
        /// Ensures that access to current node is permitted.
        /// </summary>
        /// <remarks>Redirecting to a different site root and/or culture will not pick the new site root nor the new culture.</remarks>
        private void EnsureNodeAccess()
        {
            const string tracePrefix = "EnsurePageAccess: ";

            if (_publishedContentRequest.PublishedContent == null)
            {
                throw new InvalidOperationException("There is no node.");
            }

            var path = _publishedContentRequest.PublishedContent.Path;

            if (Access.IsProtected(_publishedContentRequest.DocumentId, path))
            {
                LogHelper.Debug <PublishedContentRequest>("{0}Page is protected, check for access", () => tracePrefix);

                System.Web.Security.MembershipUser user = null;
                try
                {
                    user = System.Web.Security.Membership.GetUser();
                }
                catch (ArgumentException)
                {
                    LogHelper.Debug <PublishedContentRequest>("{0}Membership.GetUser returned ArgumentException", () => tracePrefix);
                }

                if (user == null || !Member.IsLoggedOn())
                {
                    LogHelper.Debug <PublishedContentRequest>("{0}Not logged in, redirect to login page", () => tracePrefix);
                    var loginPageId = Access.GetLoginPage(path);
                    if (loginPageId != _publishedContentRequest.DocumentId)
                    {
                        _publishedContentRequest.PublishedContent = _routingContext.PublishedContentStore.GetDocumentById(
                            _umbracoContext,
                            loginPageId);
                    }
                }
                else if (!Access.HasAccces(_publishedContentRequest.DocumentId, user.ProviderUserKey))
                {
                    LogHelper.Debug <PublishedContentRequest>("{0}Current member has not access, redirect to error page", () => tracePrefix);
                    var errorPageId = Access.GetErrorPage(path);
                    if (errorPageId != _publishedContentRequest.DocumentId)
                    {
                        _publishedContentRequest.PublishedContent = _routingContext.PublishedContentStore.GetDocumentById(
                            _umbracoContext,
                            errorPageId);
                    }
                }
                else
                {
                    LogHelper.Debug <PublishedContentRequest>("{0}Current member has access", () => tracePrefix);
                }
            }
            else
            {
                LogHelper.Debug <PublishedContentRequest>("{0}Page is not protected", () => tracePrefix);
            }
        }
Exemple #17
0
        /// <summary>
        /// Find users by name.
        /// </summary>
        /// <param name="usernameToMatch">The username to match.</param>
        /// <param name="pageIndex">The page index.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="totalRecords">Total number of records.</param>
        /// <returns>The membership user collection.</returns>
        public System.Web.Security.MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            System.Web.Security.MembershipUserCollection                  memShipUsers = new System.Web.Security.MembershipUserCollection();
            Nequeo.DataAccess.ApplicationLogin.Data.Extension.User        user         = new Nequeo.DataAccess.ApplicationLogin.Data.Extension.User();
            Nequeo.DataAccess.ApplicationLogin.Data.Extension.UserAddress userAddress  = new Nequeo.DataAccess.ApplicationLogin.Data.Extension.UserAddress();

            // Get all the users for the match.
            long usersMatched = user.Select.
                                GetRecordCount(
                u =>
                (Nequeo.Data.TypeExtenders.SqlQueryMethods.Like(u.LoginUsername, ("%" + usernameToMatch + "%")))
                );

            // Get the total number of uses.
            totalRecords = Int32.Parse(usersMatched.ToString());
            int      skipNumber  = (pageIndex * pageSize);
            DateTime createdDate = DateTime.Now;

            // Get the current set on data.
            IQueryable <Data.User> users = user.Select.QueryableProvider().
                                           Where(u =>
                                                 (Nequeo.Data.TypeExtenders.SqlQueryMethods.Like(u.LoginUsername, ("%" + usernameToMatch + "%")))).
                                           OrderBy(u => u.UserID).
                                           Take(pageSize).
                                           Skip(skipNumber);

            // For each user found.
            foreach (Data.User item in users)
            {
                // Get the current users address details
                Data.UserAddress address = userAddress.Select.SelectDataEntity(u => u.UserAddressID == item.UserAddressID);

                // Create the membership user.
                System.Web.Security.MembershipUser memShipUser =
                    new System.Web.Security.MembershipUser(
                        ProviderName,
                        item.LoginUsername,
                        item.UserID,
                        address.EmailAddress,
                        "",
                        item.Comments,
                        true,
                        item.UserSuspended,
                        createdDate,
                        createdDate,
                        createdDate,
                        createdDate,
                        createdDate);

                // Add the user to the collection.
                memShipUsers.Add(memShipUser);
            }

            // Return the collection of membership users.
            return(memShipUsers);
        }
Exemple #18
0
 public ConfirmationManager(string userName)
 {
     if (!string.IsNullOrEmpty(userName))
     {
         var user = System.Web.Security.Membership.GetUser(userName);
         if (user != null)
         {
             CurrentUser = user;
         }
     }
 }
Exemple #19
0
        public System.Net.Mail.MailMessage Get(System.Web.Security.MembershipUser mu, string templatePath, DateTime?lastRunDate)
        {
//#if DEBUG
//            Debugger.Break();
//#endif
            List <AlertPurchaseOrder> APO = ControllerManager.AlertPurchaseOrder.ShowAlert2();

            if (APO.Count == 0)
            {
                return(null);
            }

            if (Path.IsPathRooted(templatePath))
            {
                // Determine if we are running in a web context
                if (HttpContext.Current != null)
                {
                    templatePath = HttpContext.Current.Server.MapPath(templatePath);
                }
                else
                {
                    templatePath =
                        Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), templatePath);
                }
            }

            string fullMail     = File.ReadAllText(Path.Combine(templatePath, "common.htm"));
            string templateBody = File.ReadAllText(Path.Combine(templatePath, "template2.htm"));
            string lineTemplate = File.ReadAllText(Path.Combine(templatePath, "template2_line.htm"));

            string template2_lines = "";
            string subject         = HttpUtility.HtmlDecode(title);

            foreach (AlertPurchaseOrder n in APO)
            {
                string newsInfo = lineTemplate;
                newsInfo         = newsInfo.Replace("[PURCHASEORDERCODE]", n.PurchaseOrderCode);
                newsInfo         = newsInfo.Replace("[PURCHASEORDERITEMCODE]", n.PurchaseOrderItemCode);
                newsInfo         = newsInfo.Replace("[QUANTITY]", n.Quantity.ToString());
                newsInfo         = newsInfo.Replace("[GAP]", n.GAP.ToString());
                newsInfo         = newsInfo.Replace("[WAYOFDELIVERY]", n.WayOfDelivery.ToString());
                newsInfo         = newsInfo.Replace("[TYPE]", n.Destination.ToString());
                newsInfo         = newsInfo.Replace("[ARRIVAL]", n.ArrivalDate.ToShortDateString());
                template2_lines += newsInfo;
            }

            fullMail = fullMail.Replace("[BODY]", templateBody.Replace("[LINES]", template2_lines));
            fullMail = fullMail.Replace("[TITLE]", title);
            MailMessage m = new MailMessage();

            m.Body    = fullMail;
            m.Subject = subject;
            return(m);
        }
        /// <summary>
        /// Find users by name.
        /// </summary>
        /// <param name="usernameToMatch">The username to match.</param>
        /// <param name="pageIndex">The page index.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="totalRecords">Total number of records.</param>
        /// <returns>The membership user collection.</returns>
        public System.Web.Security.MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            System.Web.Security.MembershipUserCollection           memShipUsers = new System.Web.Security.MembershipUserCollection();
            Nequeo.DataAccess.CloudInteraction.Data.Extension.User user         = new Nequeo.DataAccess.CloudInteraction.Data.Extension.User();

            // Get all the users for the match.
            long usersMatched = user.Select.
                                GetRecordCount(
                u =>
                (u.ApplicationName == ApplicationName) &&
                (Nequeo.Data.TypeExtenders.SqlQueryMethods.Like(u.Username, ("%" + usernameToMatch + "%")))
                );

            // Get the total number of uses.
            totalRecords = Int32.Parse(usersMatched.ToString());
            int skipNumber = (pageIndex * pageSize);

            // Get the current set on data.
            IQueryable <Data.User> users = user.Select.QueryableProvider().
                                           Where(u =>
                                                 (u.ApplicationName == ApplicationName) &&
                                                 (Nequeo.Data.TypeExtenders.SqlQueryMethods.Like(u.Username, ("%" + usernameToMatch + "%")))).
                                           OrderBy(u => u.Username).
                                           Take(pageSize).
                                           Skip(skipNumber);

            // For each user found.
            foreach (Data.User item in users)
            {
                // Create the membership user.
                System.Web.Security.MembershipUser memShipUser =
                    new System.Web.Security.MembershipUser(
                        ProviderName,
                        item.Username,
                        item.UserID,
                        item.Email,
                        item.PasswordQuestion,
                        item.Comments,
                        item.IsApproved,
                        item.UserSuspended,
                        item.CreationDate,
                        item.LastLoginDate,
                        item.LastActivityDate,
                        item.LastPasswordChangedDate,
                        item.UserSuspendedDate);

                // Add the user to the collection.
                memShipUsers.Add(memShipUser);
            }

            // Return the collection of membership users.
            return(memShipUsers);
        }
Exemple #21
0
        public MailMessage Get(System.Web.Security.MembershipUser mu, string templatePath, DateTime?lastRunDate)
        {
//#if DEBUG
//            Debugger.Break();
//#endif

            List <AlertProduct> AP = ControllerManager.AlertProduct.ShowAlert3();

            if (AP.Count == 0)
            {
                return(null);
            }

            if (Path.IsPathRooted(templatePath))
            {
                // Determine if we are running in a web context
                if (HttpContext.Current != null)
                {
                    templatePath = HttpContext.Current.Server.MapPath(templatePath);
                }
                else
                {
                    templatePath =
                        Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), templatePath);
                }
            }

            string fullMail     = File.ReadAllText(Path.Combine(templatePath, "common.htm"));
            string templateBody = File.ReadAllText(Path.Combine(templatePath, "template3.htm"));
            string lineTemplate = File.ReadAllText(Path.Combine(templatePath, "template3_line.htm"));

            string template3_lines = "";
            string subject         = HttpUtility.HtmlDecode(title);

            foreach (AlertProduct n in AP)
            {
                string newsInfo = lineTemplate;
                newsInfo         = newsInfo.Replace("[PRODUCTCODE]", n.ProductCode);
                newsInfo         = newsInfo.Replace("[STANDARDCOST]", n.StandardCost.ToString());
                newsInfo         = newsInfo.Replace("[SUBTOTAL]", n.SubTotal.ToString());
                newsInfo         = newsInfo.Replace("[QUANTITY]", n.Quantity.ToString());
                template3_lines += newsInfo;
            }

            fullMail = fullMail.Replace("[BODY]", templateBody.Replace("[LINES]", template3_lines));
            fullMail = fullMail.Replace("[TITLE]", title);
            MailMessage m = new MailMessage();

            m.Body    = fullMail;
            m.Subject = subject;
            return(m);
        }
Exemple #22
0
        public override System.Web.Security.MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status)
        {
            if (String.IsNullOrEmpty(username) || username.Length > 256)
            {
                status = System.Web.Security.MembershipCreateStatus.InvalidUserName;
                return(null);
            }

            if (password.Length < this.MinRequiredPasswordLength)
            {
                status = System.Web.Security.MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            if (String.IsNullOrEmpty(email))
            {
                status = System.Web.Security.MembershipCreateStatus.InvalidEmail;
                return(null);
            }

            if (String.IsNullOrEmpty(passwordQuestion))
            {
                status = System.Web.Security.MembershipCreateStatus.InvalidQuestion;
                return(null);
            }

            if (String.IsNullOrEmpty(passwordAnswer))
            {
                status = System.Web.Security.MembershipCreateStatus.InvalidAnswer;
                return(null);
            }

            System.Web.Security.MembershipUser user = this.GetMembershipUser(username);
            if (user != null)
            {
                status = System.Web.Security.MembershipCreateStatus.DuplicateUserName;
                return(null);
            }

            user = this.GetMembershipUserByEmail(email);
            if (user != null)
            {
                status = System.Web.Security.MembershipCreateStatus.DuplicateEmail;
                return(null);
            }

            user = new System.Web.Security.MembershipUser(this.Name, username, 0,
                                                          email, passwordQuestion, null, isApproved, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);
            this.UpdateUserInternal(user, password, passwordAnswer);
            status = System.Web.Security.MembershipCreateStatus.Success;
            return(user);
        }
Exemple #23
0
        public virtual ActionResult AfterRegistration(string username)
        {
            string id = this.Request.QueryString["id"];

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(id) && Maps.Instance.DuradosMap.Database.GetGuidByUsername(username) == id)
            {
                System.Web.Security.MembershipUser user = System.Web.Security.Membership.Provider.GetUser(username, true);
                user.IsApproved = true;
                System.Web.Security.Membership.UpdateUser(user);
                PlugInHelper.SignIn(username);
            }
            return(Redirect("/index.aspx"));
        }
Exemple #24
0
        private void AddRowsToTable()
        {
            Sol_SupplyInventory    sol_SupplyInventory;
            Sol_SupplyInventory_Sp sol_SupplyInventory_Sp = new Sol_SupplyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString);

            System.Web.Security.MembershipUser membershipUser = System.Web.Security.Membership.GetUser(Properties.Settings.Default.UsuarioNombre);
            if (membershipUser == null)
            {
                MessageBox.Show("User does not exits, cannot add shipping containers entry");
                return;
            }

            Guid userID = (Guid)membershipUser.ProviderUserKey;

            int quantity = 0;

            foreach (DataGridViewRow row in dataGridViewShippingContainers.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }

                Int32.TryParse(row.Cells[2].Value.ToString(), out quantity);

                if (quantity == 0)
                {
                    continue;
                }

                sol_SupplyInventory = new Sol_SupplyInventory();
                ////SupplyInventoryTypes
                //"0", "Order"
                //"R", "Received Order"
                //"A", "Adjustment"
                //"S", "Shipped"
                sol_SupplyInventory.SupplyInventoryType = "R";
                sol_SupplyInventory.UserID      = userID;
                sol_SupplyInventory.Date        = Main.rc.FechaActual;
                sol_SupplyInventory.DateOrdered = DateTime.Parse("1753-1-1 12:00:00");
                //sol_SupplyInventory.ProductID = (int)row.Cells[4].Value;
                sol_SupplyInventory.ContainerID = (int)row.Cells[0].Value;
                sol_SupplyInventory.Quantity    = quantity;
                //sol_SupplyInventory.ShipmentID = shipmentId;
                sol_SupplyInventory.ReferenceNumber = textBoxReference.Text;

                sol_SupplyInventory_Sp.Insert(sol_SupplyInventory);
            }

            //dataGridViewShippingContainers.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.Security.MembershipUser logUser        = System.Web.Security.Membership.GetUser(User.Identity.Name);
            CapaNegocio.clsOrientador          usuario        = new CapaNegocio.clsOrientador();
            CapaDatos.clsDOrientador           objDatosPerfil = new CapaDatos.clsDOrientador();
            usuario       = objDatosPerfil.D_consultarOrientador(logUser.UserName.ToString());
            Session["id"] = usuario.IDOrientador1;

            lblFecha.Text = DateTime.Now.ToString("yyyy/MM/dd");
            if (!Page.IsPostBack)
            {
                cargarReuniones();
            }
        }
Exemple #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         System.Web.Security.MembershipUser logUser = System.Web.Security.Membership.GetUser(User.Identity.Name);
         CapaNegocio.clsNUsuario            usuario = new CapaNegocio.clsNUsuario();
         CapaDatos.clsUsuario objDatosPerfil        = new CapaDatos.clsUsuario();
         usuario          = objDatosPerfil.obtenerDatosUsuario(logUser.UserName.ToString());
         lblMiPerfil.Text = "Hola " + usuario.nombre;
     }
     catch (Exception ex)
     {
     }
 }
Exemple #27
0
        private void UpdateUserInternal(System.Web.Security.MembershipUser user, string password, string passwordAnswer, string passwordQuestion, bool isLockedOut)
        {
            string pass = String.Empty, answer = String.Empty;

            if (!String.IsNullOrEmpty(password))
            {
                pass = Cryptography.Encrypt(password, SecurityManager.EncryptKey, SecurityManager.EncryptIV, EncryptionAlgorithm.Rijndael);
            }
            if (!String.IsNullOrEmpty(passwordAnswer))
            {
                answer = Cryptography.Encrypt(passwordAnswer, SecurityManager.EncryptKey, SecurityManager.EncryptIV, EncryptionAlgorithm.Rijndael);
            }

            int      tokens          = 0;
            string   displayName     = user.UserName;
            string   imageUrl        = null;
            DateTime?birthDate       = null;
            Guid     confirmatioCode = Guid.NewGuid();
            User     lgUser          = null;

            if (user is User)
            {
                lgUser          = (user as User);
                tokens          = lgUser.Tokens;
                displayName     = lgUser.DisplayName;
                imageUrl        = lgUser.ImageUrl;
                confirmatioCode = lgUser.ConfirmationCode;
                if (lgUser.BirthDate.CompareTo(DateTime.MinValue) != 0)
                {
                    birthDate = lgUser.BirthDate;
                }
            }

            using (SqlCommand cmd = SqlHelper.ExecuteNonQuery(_connectionString, "dbo.lg_Users_SaveUser",
                                                              SqlHelper.CreateInputParam("@UserName", SqlDbType.NVarChar, user.UserName),
                                                              SqlHelper.CreateInputParam("@Password", SqlDbType.NVarChar, pass),
                                                              SqlHelper.CreateInputParam("@DisplayName", SqlDbType.NVarChar, displayName),
                                                              SqlHelper.CreateInputParam("@ImageUrl", SqlDbType.NVarChar, imageUrl),
                                                              SqlHelper.CreateInputParam("@Email", SqlDbType.NVarChar, user.Email),
                                                              SqlHelper.CreateInputParam("@ConfirmationCode", SqlDbType.UniqueIdentifier, confirmatioCode),
                                                              SqlHelper.CreateInputParam("@PasswordQuestion", SqlDbType.NVarChar, passwordQuestion),
                                                              SqlHelper.CreateInputParam("@PasswordAnswer", SqlDbType.NVarChar, answer),
                                                              SqlHelper.CreateInputParam("@IsApproved", SqlDbType.NVarChar, user.IsApproved),
                                                              SqlHelper.CreateInputParam("@IsLockedOut", SqlDbType.NVarChar, isLockedOut),
                                                              SqlHelper.CreateInputParam("@Tokens", SqlDbType.Int, tokens),
                                                              SqlHelper.CreateInputParam("@BirthDate", SqlDbType.DateTime, birthDate)))
            {
            }
        }
        protected virtual bool ResetPassAndSendUserAnEmail(string username, ref string message)
        {
            try {
                if (ExtranetSecurity.HasExtranetUserPrefix())
                {
                    string domainUser = Sitecore.Context.Domain.GetFullName(ExtranetSecurity.ExtranetUserPrefix() + username);
                    User   u          = (User)User.FromName(domainUser, AccountType.User);
                    if (!Sitecore.Security.Accounts.User.Exists(domainUser))
                    {
                        //throw new System.Security.Authentication.AuthenticationException(domainUser + " does not exist.");
                        message = username + FormTextUtility.Provider.GetTextByKey("/ForgotPassword/UserDoesntExist");
                    }
                    else if (u != null)
                    {
                        System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(domainUser);
                        string newPass = user.ResetPassword();

                        MailMessage m = new MailMessage();
                        m.From = new MailAddress(ExtranetSecurity.FromEmailAddress());
                        m.To.Add(new MailAddress(u.Profile.Email));
                        m.Subject = string.Format("{0} {1}",
                                                  FormTextUtility.Provider.GetTextByKey("/ForgotPassword/EmailResetPasswordSubject"),
                                                  HttpContext.Current.Request.Url.Host);
                        m.Body = string.Format("{0} {1},\r\n{2}: {3}",
                                               FormTextUtility.Provider.GetTextByKey("/ForgotPassword/EmailHello"),
                                               u.Profile.FullName,
                                               FormTextUtility.Provider.GetTextByKey("/ForgotPassword/EmailYourNewPasswordIs"),
                                               newPass);
                        Sitecore.MainUtil.SendMail(m);
                        message = FormTextUtility.Provider.GetTextByKey("/ForgotPassword/NewPasswordWasSent");

                        return(true);
                    }
                    else
                    {
                        message = username + FormTextUtility.Provider.GetTextByKey("/ForgotPassword/UserDoesntExist");
                    }
                }
                else
                {
                    message = "." + FormTextUtility.Provider.GetTextByKey("/ForgotPassword/ConfigurationError");
                }
            } catch (System.Security.Authentication.AuthenticationException) {
                message = FormTextUtility.Provider.GetTextByKey("/ForgotPassword/AuthenticationError");
            } catch (System.Configuration.ConfigurationException) {
                message = FormTextUtility.Provider.GetTextByKey("/ForgotPassword/ConfigurationError");
            }
            return(false);
        }
Exemple #29
0
        void BindUser()
        {
            if (Request.Cookies["RememberMe"] != null)
            {
                if (Request.Cookies["AvenueUserLogin"] != null)
                {
                    aLogin.RememberMeSet = true;
                }
            }

            if (aLogin.UserName != null && aLogin.UserName != "")
            {
                System.Web.Security.MembershipUser membershipUser = System.Web.Security.Membership.GetUser(aLogin.UserName);
            }
        }
Exemple #30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         System.Web.Security.MembershipUser logUser        = System.Web.Security.Membership.GetUser(User.Identity.Name);
         CapaNegocio.clsOrientador          usuario        = new CapaNegocio.clsOrientador();
         CapaDatos.clsDOrientador           objDatosPerfil = new CapaDatos.clsDOrientador();
         usuario          = objDatosPerfil.D_consultarOrientador(logUser.UserName.ToString());
         Session["id"]    = usuario.IDOrientador1;
         lblMiPerfil.Text = "Hola " + usuario.NombreOrientador;
     }
     catch (Exception ex)
     {
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {

            }
            else
            {
                Response.Redirect("Protected.aspx");
            }

            u = System.Web.Security.Membership.GetUser(User.Identity.Name);
            EmailBox.Text = u.Email;
            UsernameBox.Text = u.UserName;

            NameBox.Text = System.Web.HttpContext.Current.User.Identity.Name;
            //SurnameBox.Text = System.Web.HttpContext.Current.User.Identity.;
        }
        public override System.Web.Security.MembershipUser CreateUser(
            string username, 
            string password, 
            string email, 
            string passwordQuestion, 
            string passwordAnswer, 
            bool isApproved, 
            object providerUserKey, 
            out System.Web.Security.MembershipCreateStatus status)
        {

            if (string.IsNullOrEmpty(username))
            {
                status = System.Web.Security.MembershipCreateStatus.InvalidUserName;
                return null;
            }


            FWSync.IDAL.IUser dal = FWSync.DALFactory.DataAccess.CreateUser();

            bool isexist = dal.ValidateUserExist(username);

            if (isexist)
            {
                status = System.Web.Security.MembershipCreateStatus.DuplicateUserName;
                return null;
            }



            UserInfo us = new UserInfo();

            us.UserName = username;

            //这里要用到md5加密
            us.PassWord = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password,"MD5");
            //us.PassWord = password;

            int userid = dal.InsertUser(us);

            status = System.Web.Security.MembershipCreateStatus.Success;

            System.Web.Security.MembershipUser user
                = new System.Web.Security.MembershipUser(
                    "MyMemberShip",
                    username,
                    userid,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    true,
                    false,
                    DateTime.Now,
                    DateTime.Now,
                    DateTime.Now,
                    DateTime.Now,
                    DateTime.Now
                    );

            return user;

        }
		public HybridMembershipUser(System.Web.Security.MembershipUser membershipUser, IUser user, string provider)
			: base(user, provider) {
			primaryMembershipUser = membershipUser;
		}