コード例 #1
0
        private void AddChangePasswordControl()
        {
            TemplateHelper helper;

            string provider = Utils.GetMembershipProvider(Context);
            //Exit if membership provider not defined
            if (provider == null || !Utils.IsProviderConfigured())
            {
                Controls.Add(new LiteralControl(LocalizedString.GetString("FBAPackFeatures", "MembershipNotConfigured")));
                return;
            }

            if (SPContext.Current.Web.CurrentUser == null)
            {
                //Login Control won't work with SP2010, so for now, just don't show a control at all
                //Login ctlLogin = new Login();
                //this.Controls.Add(ctlLogin);
            }
            else
            {
                _ctlChangePassword = new System.Web.UI.WebControls.ChangePassword();
                _ctlChangePassword.ChangePasswordTemplate = new TemplateLoader(ChangePasswordTemplate, Page);
                _ctlChangePassword.SuccessTemplate = new TemplateLoader(SuccessTemplate, Page);
                _ctlChangePassword.MembershipProvider = provider;
                _ctlChangePassword.ChangePasswordFailureText = ChangePasswordFailureText;

                if (!String.IsNullOrEmpty(CancelDestinationPageUrl))
                {
                    _ctlChangePassword.CancelDestinationPageUrl = CancelDestinationPageUrl;
                }
                else
                {
                    string url = SPUtility.OriginalServerRelativeRequestUrl;
                    SPUtility.DetermineRedirectUrl(url, SPRedirectFlags.UseSource, this.Context, null, out url);
                    _ctlChangePassword.CancelDestinationPageUrl = url;
                }

                if (!String.IsNullOrEmpty(ContinueDestinationPageUrl))
                {
                    _ctlChangePassword.ContinueDestinationPageUrl = ContinueDestinationPageUrl;
                }
                else
                {
                    string url = SPUtility.OriginalServerRelativeRequestUrl;
                    SPUtility.DetermineRedirectUrl(url, SPRedirectFlags.UseSource, this.Context, null, out url);
                    _ctlChangePassword.ContinueDestinationPageUrl = url;
                }

                _ctlChangePassword.ToolTip = ToolTip;
                _ctlChangePassword.SuccessPageUrl = SuccessPageUrl;
                _ctlChangePassword.NewPasswordRegularExpressionErrorMessage = NewPasswordRegularExpressionErrorMessage;

                //ChangePasswordTemplate
                //have to initially force DisplayUserName true to access template
                _ctlChangePassword.DisplayUserName = true;
                helper = new TemplateHelper(_ctlChangePassword.ChangePasswordTemplateContainer);
                _ctlChangePassword.DisplayUserName = DisplayUserName;
                helper.SetText("ChangePasswordTitle", ChangePasswordTitleText);
                helper.SetText("Instruction", InstructionText);
                helper.SetVisible("UserNameRow", DisplayUserName);
                helper.SetText("UserNameLabel", UserNameLabelText);
                helper.SetValidation("UserNameRequired", UserNameRequiredErrorMessage, this.UniqueID);
                helper.SetText("CurrentPasswordLabel", PasswordLabelText);
                helper.SetValidation("CurrentPasswordRequired", PasswordRequiredErrorMessage, this.UniqueID);
                helper.SetText("NewPasswordLabel", NewPasswordLabelText);
                helper.SetValidation("NewPasswordRequired", NewPasswordRequiredErrorMessage, this.UniqueID);
                helper.SetText("PasswordHint", PasswordHintText);
                helper.SetVisible("PasswordHintRow", !String.IsNullOrEmpty(PasswordHintText));
                helper.SetText("ConfirmNewPasswordLabel", ConfirmNewPasswordLabelText);
                helper.SetValidation("ConfirmNewPasswordRequired", ConfirmPasswordRequiredErrorMessage, this.UniqueID);
                helper.SetValidation("ConfirmNewPasswordCompare", ConfirmPasswordCompareErrorMessage, this.UniqueID);

                switch (ChangePasswordButtonType)
                {
                    case ButtonType.Button:
                        helper.SetButton("ChangePasswordButton", ChangePasswordButtonText, this.UniqueID);
                        helper.SetVisible("ChangePasswordButton", true);
                        break;

                    case ButtonType.Image:
                        helper.SetImageButton("ChangePasswordImageButton", ChangePasswordButtonImageUrl, ChangePasswordButtonText, this.UniqueID);
                        helper.SetVisible("ChangePasswordImageButton", true);
                        break;

                    case ButtonType.Link:
                        helper.SetButton("ChangePasswordLinkButton", ChangePasswordButtonText, this.UniqueID);
                        helper.SetVisible("ChangePasswordLinkButton", true);
                        break;
                }

                switch (CancelButtonType)
                {
                    case ButtonType.Button:
                        helper.SetButton("CancelButton", CancelButtonText, this.UniqueID);
                        helper.SetVisible("CancelButton", true);
                        break;

                    case ButtonType.Image:
                        helper.SetImageButton("CancelImageButton", CancelButtonImageUrl, CancelButtonText, this.UniqueID);
                        helper.SetVisible("CancelImageButton", true);
                        break;

                    case ButtonType.Link:
                        helper.SetButton("CancelLinkButton", CancelButtonText, this.UniqueID);
                        helper.SetVisible("CancelLinkButton", true);
                        break;
                }

                helper.SetVisible("EditProfileRow", !String.IsNullOrEmpty(EditProfileUrl));
                helper.SetImage("EditProfileIcon", EditProfileIconUrl, EditProfileText,false);
                helper.SetLink("EditProfileLink", EditProfileText, EditProfileUrl);

                helper.SetVisible("HelpPageRow", !String.IsNullOrEmpty(HelpPageUrl));
                helper.SetImage("HelpPageIcon", HelpPageIconUrl, HelpPageText, false);
                helper.SetLink("HelpPageLink", HelpPageText, HelpPageUrl);

                helper.SetVisible("CreateUserRow", !String.IsNullOrEmpty(CreateUserUrl));
                helper.SetImage("CreateUserIcon", CreateUserIconUrl, CreateUserText, false);
                helper.SetLink("CreateUserLink", CreateUserText, CreateUserUrl);

                helper.SetVisible("PasswordRecoveryRow", !String.IsNullOrEmpty(PasswordRecoveryUrl));
                helper.SetImage("PasswordRecoveryIcon", PasswordRecoveryIconUrl, PasswordRecoveryText, false);
                helper.SetLink("PasswordRecoveryLink", PasswordRecoveryText, PasswordRecoveryUrl);

                //SuccessTemplate
                helper = new TemplateHelper(_ctlChangePassword.SuccessTemplateContainer);
                helper.SetText("Success", SuccessText);

                helper.SetVisible("EditProfileRow", !String.IsNullOrEmpty(EditProfileUrl));
                helper.SetImage("EditProfileIcon", EditProfileIconUrl, EditProfileText, false);
                helper.SetLink("EditProfileLink", EditProfileText, EditProfileUrl);

                switch (ContinueButtonType)
                {
                    case ButtonType.Button:
                        helper.SetButton("ContinueButton", ContinueButtonText, this.UniqueID);
                        helper.SetVisible("ContinueButton", true);
                        break;

                    case ButtonType.Image:
                        helper.SetImageButton("ContinueImageButton", ContinueButtonImageUrl, ContinueButtonText, this.UniqueID);
                        helper.SetVisible("ContinueImageButton", true);
                        break;

                    case ButtonType.Link:
                        helper.SetButton("ContinueLinkButton", ContinueButtonText, this.UniqueID);
                        helper.SetVisible("ContinueLinkButton", true);
                        break;
                }

                //_ctlChangePassword.ChangingPassword += new LoginCancelEventHandler(ctlChangePassword_ChangingPassword);
                _ctlChangePassword.ChangedPassword += new EventHandler(_ctlChangePassword_ChangedPassword);
                _ctlChangePassword.Load += new EventHandler(_ctlChangePassword_Load);

                this.Controls.Add(_ctlChangePassword);
            }
        }
コード例 #2
0
        private void AddChangePasswordControl()
        {
            TemplateHelper helper;

            string provider = Utils.GetMembershipProvider(Context);

            //Exit if membership provider not defined
            if (provider == null || !Utils.IsProviderConfigured())
            {
                Controls.Add(new LiteralControl(LocalizedString.GetString("FBAPackFeatures", "MembershipNotConfigured")));
                return;
            }

            if (SPContext.Current.Web.CurrentUser == null)
            {
                //Login Control won't work with SP2010, so for now, just don't show a control at all
                //Login ctlLogin = new Login();
                //this.Controls.Add(ctlLogin);
            }
            else
            {
                _ctlChangePassword = new System.Web.UI.WebControls.ChangePassword();
                _ctlChangePassword.ChangePasswordTemplate    = new TemplateLoader(ChangePasswordTemplate, Page);
                _ctlChangePassword.SuccessTemplate           = new TemplateLoader(SuccessTemplate, Page);
                _ctlChangePassword.MembershipProvider        = provider;
                _ctlChangePassword.ChangePasswordFailureText = ChangePasswordFailureText;

                if (!String.IsNullOrEmpty(CancelDestinationPageUrl))
                {
                    _ctlChangePassword.CancelDestinationPageUrl = CancelDestinationPageUrl;
                }
                else
                {
                    string url = SPUtility.OriginalServerRelativeRequestUrl;
                    SPUtility.DetermineRedirectUrl(url, SPRedirectFlags.UseSource, this.Context, null, out url);
                    _ctlChangePassword.CancelDestinationPageUrl = url;
                }

                if (!String.IsNullOrEmpty(ContinueDestinationPageUrl))
                {
                    _ctlChangePassword.ContinueDestinationPageUrl = ContinueDestinationPageUrl;
                }
                else
                {
                    string url = SPUtility.OriginalServerRelativeRequestUrl;
                    SPUtility.DetermineRedirectUrl(url, SPRedirectFlags.UseSource, this.Context, null, out url);
                    _ctlChangePassword.ContinueDestinationPageUrl = url;
                }


                _ctlChangePassword.ToolTip        = ToolTip;
                _ctlChangePassword.SuccessPageUrl = SuccessPageUrl;
                _ctlChangePassword.NewPasswordRegularExpressionErrorMessage = NewPasswordRegularExpressionErrorMessage;

                //ChangePasswordTemplate
                //have to initially force DisplayUserName true to access template
                _ctlChangePassword.DisplayUserName = true;
                helper = new TemplateHelper(_ctlChangePassword.ChangePasswordTemplateContainer);
                _ctlChangePassword.DisplayUserName = DisplayUserName;
                helper.SetText("ChangePasswordTitle", ChangePasswordTitleText);
                helper.SetText("Instruction", InstructionText);
                helper.SetVisible("UserNameRow", DisplayUserName);
                helper.SetText("UserNameLabel", UserNameLabelText);
                helper.SetValidation("UserNameRequired", UserNameRequiredErrorMessage, this.UniqueID);
                helper.SetText("CurrentPasswordLabel", PasswordLabelText);
                helper.SetValidation("CurrentPasswordRequired", PasswordRequiredErrorMessage, this.UniqueID);
                helper.SetText("NewPasswordLabel", NewPasswordLabelText);
                helper.SetValidation("NewPasswordRequired", NewPasswordRequiredErrorMessage, this.UniqueID);
                helper.SetText("PasswordHint", PasswordHintText);
                helper.SetVisible("PasswordHintRow", !String.IsNullOrEmpty(PasswordHintText));
                helper.SetText("ConfirmNewPasswordLabel", ConfirmNewPasswordLabelText);
                helper.SetValidation("ConfirmNewPasswordRequired", ConfirmPasswordRequiredErrorMessage, this.UniqueID);
                helper.SetValidation("ConfirmNewPasswordCompare", ConfirmPasswordCompareErrorMessage, this.UniqueID);

                switch (ChangePasswordButtonType)
                {
                case ButtonType.Button:
                    helper.SetButton("ChangePasswordButton", ChangePasswordButtonText, this.UniqueID);
                    helper.SetVisible("ChangePasswordButton", true);
                    break;

                case ButtonType.Image:
                    helper.SetImageButton("ChangePasswordImageButton", ChangePasswordButtonImageUrl, ChangePasswordButtonText, this.UniqueID);
                    helper.SetVisible("ChangePasswordImageButton", true);
                    break;

                case ButtonType.Link:
                    helper.SetButton("ChangePasswordLinkButton", ChangePasswordButtonText, this.UniqueID);
                    helper.SetVisible("ChangePasswordLinkButton", true);
                    break;
                }

                switch (CancelButtonType)
                {
                case ButtonType.Button:
                    helper.SetButton("CancelButton", CancelButtonText, this.UniqueID);
                    helper.SetVisible("CancelButton", true);
                    break;

                case ButtonType.Image:
                    helper.SetImageButton("CancelImageButton", CancelButtonImageUrl, CancelButtonText, this.UniqueID);
                    helper.SetVisible("CancelImageButton", true);
                    break;

                case ButtonType.Link:
                    helper.SetButton("CancelLinkButton", CancelButtonText, this.UniqueID);
                    helper.SetVisible("CancelLinkButton", true);
                    break;
                }

                helper.SetVisible("EditProfileRow", !String.IsNullOrEmpty(EditProfileUrl));
                helper.SetImage("EditProfileIcon", EditProfileIconUrl, EditProfileText, false);
                helper.SetLink("EditProfileLink", EditProfileText, EditProfileUrl);

                helper.SetVisible("HelpPageRow", !String.IsNullOrEmpty(HelpPageUrl));
                helper.SetImage("HelpPageIcon", HelpPageIconUrl, HelpPageText, false);
                helper.SetLink("HelpPageLink", HelpPageText, HelpPageUrl);

                helper.SetVisible("CreateUserRow", !String.IsNullOrEmpty(CreateUserUrl));
                helper.SetImage("CreateUserIcon", CreateUserIconUrl, CreateUserText, false);
                helper.SetLink("CreateUserLink", CreateUserText, CreateUserUrl);

                helper.SetVisible("PasswordRecoveryRow", !String.IsNullOrEmpty(PasswordRecoveryUrl));
                helper.SetImage("PasswordRecoveryIcon", PasswordRecoveryIconUrl, PasswordRecoveryText, false);
                helper.SetLink("PasswordRecoveryLink", PasswordRecoveryText, PasswordRecoveryUrl);

                //SuccessTemplate
                helper = new TemplateHelper(_ctlChangePassword.SuccessTemplateContainer);
                helper.SetText("Success", SuccessText);

                helper.SetVisible("EditProfileRow", !String.IsNullOrEmpty(EditProfileUrl));
                helper.SetImage("EditProfileIcon", EditProfileIconUrl, EditProfileText, false);
                helper.SetLink("EditProfileLink", EditProfileText, EditProfileUrl);

                switch (ContinueButtonType)
                {
                case ButtonType.Button:
                    helper.SetButton("ContinueButton", ContinueButtonText, this.UniqueID);
                    helper.SetVisible("ContinueButton", true);
                    break;

                case ButtonType.Image:
                    helper.SetImageButton("ContinueImageButton", ContinueButtonImageUrl, ContinueButtonText, this.UniqueID);
                    helper.SetVisible("ContinueImageButton", true);
                    break;

                case ButtonType.Link:
                    helper.SetButton("ContinueLinkButton", ContinueButtonText, this.UniqueID);
                    helper.SetVisible("ContinueLinkButton", true);
                    break;
                }

                //_ctlChangePassword.ChangingPassword += new LoginCancelEventHandler(ctlChangePassword_ChangingPassword);
                _ctlChangePassword.ChangedPassword += new EventHandler(_ctlChangePassword_ChangedPassword);
                _ctlChangePassword.Load            += new EventHandler(_ctlChangePassword_Load);

                this.Controls.Add(_ctlChangePassword);
            }
        }
コード例 #3
0
        private void AddPasswordRecoveryControl()
        {
            TemplateHelper helper;

            string provider = Utils.GetMembershipProvider(Context);

            //Exit if membership provider not defined
            if (provider == null || !Utils.IsProviderConfigured())
            {
                Controls.Add(new LiteralControl(LocalizedString.GetString("FBAPackFeatures", "MembershipNotConfigured")));
                return;
            }

            /* bms I couldn't figure out how to set the smtp server from code so I added the SendMailError as a hack for now */

            _ctlPasswordRecovery = new System.Web.UI.WebControls.PasswordRecovery();
            _ctlPasswordRecovery.UserNameTemplate = new TemplateLoader(UserNameTemplate, Page);
            _ctlPasswordRecovery.SuccessTemplate  = new TemplateLoader(SuccessTemplate, Page);
            _ctlPasswordRecovery.QuestionTemplate = new TemplateLoader(QuestionTemplate, Page);
            //bms Added the event to catch the error and send our own email
            _ctlPasswordRecovery.SendMailError      += new SendMailErrorEventHandler(_ctlPasswordRecovery_SendMailError);
            _ctlPasswordRecovery.VerifyingUser      += new LoginCancelEventHandler(_ctlPasswordRecovery_VerifyingUser);
            _ctlPasswordRecovery.SendingMail        += new MailMessageEventHandler(_ctlPasswordRecovery_SendingMail);
            _ctlPasswordRecovery.MembershipProvider  = provider;
            _ctlPasswordRecovery.GeneralFailureText  = GeneralFailureText;
            _ctlPasswordRecovery.QuestionFailureText = QuestionFailureText;
            _ctlPasswordRecovery.UserNameFailureText = UserNameFailureText;

            //UsernameTemplate
            helper = new TemplateHelper(_ctlPasswordRecovery.UserNameTemplateContainer);
            helper.SetText("UserNameInstruction", UserNameInstructionText);
            helper.SetText("UserNameLabel", UserNameLabelText);
            helper.SetText("UserNameTitle", UserNameTitleText);
            helper.SetValidation("UserNameRequired", UserNameRequiredErrorMessage, this.UniqueID);
            switch (SubmitButtonType)
            {
            case ButtonType.Button:
                helper.SetButton("SubmitButton", SubmitButtonText, this.UniqueID);
                helper.SetVisible("SubmitButton", true);
                break;

            case ButtonType.Image:
                helper.SetImageButton("SubmitImageButton", SubmitButtonImageUrl, SubmitButtonText, this.UniqueID);
                helper.SetVisible("SubmitImageButton", true);
                break;

            case ButtonType.Link:
                helper.SetButton("SubmitLinkButton", SubmitButtonText, this.UniqueID);
                helper.SetVisible("SubmitLinkButton", true);
                break;
            }

            //QuestionTemplate
            helper = new TemplateHelper(_ctlPasswordRecovery.QuestionTemplateContainer);
            helper.SetText("QuestionInstruction", QuestionInstructionText);
            helper.SetText("UserNameLabel", UserNameLabelText);
            helper.SetText("QuestionLabel", QuestionLabelText);
            helper.SetText("QuestionTitle", QuestionTitleText);
            helper.SetValidation("AnswerRequired", AnswerRequiredErrorMessage, this.UniqueID);
            switch (SubmitButtonType)
            {
            case ButtonType.Button:
                helper.SetButton("SubmitButton", SubmitButtonText, this.UniqueID);
                helper.SetVisible("SubmitButton", true);
                break;

            case ButtonType.Image:
                helper.SetImageButton("SubmitImageButton", SubmitButtonImageUrl, SubmitButtonText, this.UniqueID);
                helper.SetVisible("SubmitImageButton", true);
                break;

            case ButtonType.Link:
                helper.SetButton("SubmitLinkButton", SubmitButtonText, this.UniqueID);
                helper.SetVisible("SubmitLinkButton", true);
                break;
            }

            //SuccessTemplate
            helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer);
            helper.SetText("Success", SuccessText);

            this.Controls.Add(_ctlPasswordRecovery);
        }
コード例 #4
0
        private void AddCreateUserControl()
        {
            TemplateHelper helper;
            string provider = Utils.GetMembershipProvider(Context);
            //Exit if membership provider not defined
            if (provider == null || !Utils.IsProviderConfigured())
            {
                Controls.Add(new LiteralControl(LocalizedString.GetString("FBAPackFeatures", "MembershipNotConfigured")));
                return;
            }

            cuw = new MembershipRequestControl();
            cuw.CreateUserStep.ContentTemplate = new TemplateLoader(CreateUserStepTemplate, Page);
            cuw.CompleteStep.ContentTemplate = new TemplateLoader(CompleteStepTemplate, Page);
            cuw.ID = "FBACreateUserWizard";
            cuw.AutoGeneratePassword = AutoGeneratePassword;
            cuw.MembershipProvider = provider;
            cuw.DuplicateEmailErrorMessage = DuplicateEmailErrorMessage;
            cuw.DuplicateUserNameErrorMessage = DuplicateUserNameErrorMessage;
            cuw.EmailRegularExpressionErrorMessage = EmailRegularExpressionErrorMessage;
            cuw.InvalidPasswordErrorMessage = _InvalidPasswordErrorMessage;
            cuw.InvalidAnswerErrorMessage = InvalidAnswerErrorMessage;
            cuw.InvalidEmailErrorMessage = InvalidEmailErrorMessage;
            cuw.InvalidQuestionErrorMessage = InvalidQuestionErrorMessage;
            cuw.LoginCreatedUser = false;
            cuw.SPLoginCreatedUser = LoginCreatedUser;
            cuw.UnknownErrorMessage = UnknownErrorMessage;
            cuw.DefaultGroup = GroupName;
            cuw.CreateUserStep.CustomNavigationTemplateContainer.Controls[0].Visible = false;

            if (!String.IsNullOrEmpty(FinishDestinationPageUrl))
            {
                cuw.FinishDestinationPageUrl = FinishDestinationPageUrl;
            }
            else
            {
                string url = SPUtility.OriginalServerRelativeRequestUrl;
                SPUtility.DetermineRedirectUrl(url, SPRedirectFlags.UseSource, this.Context, null, out url);
                cuw.FinishDestinationPageUrl = url;
            }

            if (!String.IsNullOrEmpty(CancelDestinationPageUrl))
            {
                cuw.CancelDestinationPageUrl = CancelDestinationPageUrl;
            }
            else
            {
                string url = SPUtility.GetPageUrlPath(HttpContext.Current);
                SPUtility.DetermineRedirectUrl(url, SPRedirectFlags.UseSource, this.Context, null, out url);
                cuw.CancelDestinationPageUrl = url;
            }

            //CreateUserStep
            helper = new TemplateHelper(cuw.CreateUserStep.ContentTemplateContainer);

            helper.SetCSS("MembershipRequestTable", CssClass);
            helper.SetText("Header", HeaderText);
            helper.SetText("Instruction", InstructionText);
            helper.SetText("UserNameLabel", UserNameLabelText);
            helper.SetValidation("UserNameRequired", UserNameRequiredErrorMessage, this.UniqueID);
            helper.SetText("FirstNameLabel", FirstNameLabelText);
            helper.SetValidation("FirstNameRequired", FirstNameRequiredErrorMessage, this.UniqueID);
            helper.SetText("LastNameLabel", LastNameLabelText);
            helper.SetValidation("LastNameRequired", LastNameRequiredErrorMessage, this.UniqueID);
            helper.SetText("EmailLabel", EmailLabelText);
            helper.SetValidation("EmailRequired", EmailRequiredErrorMessage, this.UniqueID);

            if (!AutoGeneratePassword)
            {
                helper.SetVisible("PasswordRow", true);
                helper.SetVisible("ConfirmPasswordRow", true);
                helper.SetVisible("ConfirmPasswordCompareRow", true);
                helper.SetText("PasswordLabel", PasswordLabelText);
                helper.SetValidation("PasswordRequired", PasswordRequiredErrorMessage, this.UniqueID);
                helper.SetText("ConfirmPasswordLabel", ConfirmPasswordLabelText);
                helper.SetValidation("ConfirmPasswordRequired", ConfirmPasswordRequiredErrorMessage, this.UniqueID);
                helper.SetValidation("ConfirmPasswordCompare", ConfirmPasswordCompareErrorMessage, this.UniqueID);
            }

            if (Utils.BaseMembershipProvider().RequiresQuestionAndAnswer)
            {
                helper.SetVisible("QuestionRow", true);
                helper.SetVisible("AnswerRow", true);
                helper.SetText("QuestionLabel", QuestionLabelText);
                helper.SetValidation("QuestionRequired", QuestionRequiredErrorMessage, this.UniqueID);
                helper.SetText("AnswerLabel", AnswerLabelText);
                helper.SetValidation("AnswerRequired", AnswerRequiredErrorMessage, this.UniqueID);
            }

            if (CaptchaValidation)
            {
                helper.SetVisible("HipPictureRow", true);
                helper.SetVisible("HipAnswerRow", true);
                helper.SetText("HipPictureLabel", HipPictureLabelText);
                helper.SetText("HipInstructionsLabel", HipInstructionsLabelText);
                helper.SetText("HipPictureDescriptionLabel", HipPictureDescription);
                helper.SetText("HipAnswerLabel", HipCharactersLabelText);
                helper.SetValidation("HipAnswerValidator", HipErrorMessage, this.UniqueID);
                helper.SetButton("HipReset", HipResetLabelText, "");
            }
            switch (CreateUserButtonType)
            {
                case ButtonType.Button:
                    helper.SetButton("CreateUserButton", CreateUserButtonText, this.UniqueID);
                    helper.SetVisible("CreateUserButton", true);
                    break;

                case ButtonType.Image:
                    helper.SetImageButton("CreateUserImageButton", CreateUserButtonImageUrl, CreateUserButtonText, this.UniqueID);
                    helper.SetVisible("CreateUserImageButton", true);
                    break;

                case ButtonType.Link:
                    helper.SetButton("CreateUserLinkButton", CreateUserButtonText, this.UniqueID);
                    helper.SetVisible("CreateUserLinkButton", true);
                    break;
            }

            if (DisplayCancelButton)
            {
                switch (CancelButtonType)
                {
                    case ButtonType.Button:
                        helper.SetButton("CancelButton", CancelButtonText, this.UniqueID);
                        helper.SetVisible("CancelButton", true);
                        break;

                    case ButtonType.Image:
                        helper.SetImageButton("CancelImageButton", CancelButtonImageUrl, CancelButtonText, this.UniqueID);
                        helper.SetVisible("CancelImageButton", true);
                        break;

                    case ButtonType.Link:
                        helper.SetButton("CancelLinkButton", CancelButtonText, this.UniqueID);
                        helper.SetVisible("CancelLinkButton", true);
                        break;
                }
            }

            //SuccessTemplate
            helper = new TemplateHelper(cuw.CompleteStep.ContentTemplateContainer);
            helper.SetText("CompleteSuccess", CompleteSuccessText);

            helper.SetVisible("EditProfileRow", !String.IsNullOrEmpty(EditProfileUrl));
            helper.SetImage("EditProfileIcon", EditProfileIconUrl, EditProfileText, false);
            helper.SetLink("EditProfileLink", EditProfileText, EditProfileUrl);

            switch (ContinueButtonType)
            {
                case ButtonType.Button:
                    helper.SetButton("ContinueButton", ContinueButtonText, this.UniqueID);
                    helper.SetVisible("ContinueButton", true);
                    break;

                case ButtonType.Image:
                    helper.SetImageButton("ContinueImageButton", ContinueButtonImageUrl, ContinueButtonText, this.UniqueID);
                    helper.SetVisible("ContinueImageButton", true);
                    break;

                case ButtonType.Link:
                    helper.SetButton("ContinueLinkButton", ContinueButtonText, this.UniqueID);
                    helper.SetVisible("ContinueLinkButton", true);
                    break;
            }

            Controls.Add(cuw);
        }
コード例 #5
0
        private void SendEmail()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite _site = new SPSite(SPContext.Current.Site.ID, SPContext.Current.Site.Zone))
                {
                    using (SPWeb _web = _site.OpenWeb(SPContext.Current.Web.ID))
                    {
                        if (_web != null)
                        {

                            _site.AllowUnsafeUpdates = true;
                            _web.AllowUnsafeUpdates = true;

                            PasswordRecovery prc = _ctlPasswordRecovery;
                            MembershipUser currentUser = Utils.BaseMembershipProvider(_web.Site).GetUser(prc.UserName, false);
                            MembershipRequest membershipitem = MembershipRequest.GetMembershipRequest(currentUser, _web);

                            membershipitem.PasswordQuestion = currentUser.PasswordQuestion;
                            membershipitem.Password = currentUser.ResetPassword(prc.Answer);

                            if (!MembershipRequest.SendPasswordRecoveryEmail(membershipitem, _web))
                            {
                                TemplateHelper helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer);
                                helper.SetText("Success", LocalizedString.GetString("FBAPackPasswordRecoveryWebPart", "ErrorSendingEmail"));
                            }

                        }
                    }
                }
            });
        }
コード例 #6
0
        private void AddPasswordRecoveryControl()
        {
            TemplateHelper helper;

            string provider = Utils.GetMembershipProvider(Context);
            //Exit if membership provider not defined
            if (provider == null || !Utils.IsProviderConfigured())
            {
                Controls.Add(new LiteralControl(LocalizedString.GetString("FBAPackFeatures", "MembershipNotConfigured")));
                return;
            }

            /* bms I couldn't figure out how to set the smtp server from code so I added the SendMailError as a hack for now */

            _ctlPasswordRecovery = new System.Web.UI.WebControls.PasswordRecovery();
            _ctlPasswordRecovery.UserNameTemplate = new TemplateLoader(UserNameTemplate, Page);
            _ctlPasswordRecovery.SuccessTemplate = new TemplateLoader(SuccessTemplate, Page);
            _ctlPasswordRecovery.QuestionTemplate = new TemplateLoader(QuestionTemplate, Page);
            //bms Added the event to catch the error and send our own email
            _ctlPasswordRecovery.SendMailError += new SendMailErrorEventHandler(_ctlPasswordRecovery_SendMailError);
            _ctlPasswordRecovery.VerifyingUser += new LoginCancelEventHandler(_ctlPasswordRecovery_VerifyingUser);
            _ctlPasswordRecovery.SendingMail += new MailMessageEventHandler(_ctlPasswordRecovery_SendingMail);
            _ctlPasswordRecovery.MembershipProvider = provider;
            _ctlPasswordRecovery.GeneralFailureText = GeneralFailureText;
            _ctlPasswordRecovery.QuestionFailureText = QuestionFailureText;
            _ctlPasswordRecovery.UserNameFailureText = UserNameFailureText;

            //UsernameTemplate
            helper = new TemplateHelper(_ctlPasswordRecovery.UserNameTemplateContainer);
            helper.SetText("UserNameInstruction", UserNameInstructionText);
            helper.SetText("UserNameLabel", UserNameLabelText);
            helper.SetText("UserNameTitle", UserNameTitleText);
            helper.SetValidation("UserNameRequired", UserNameRequiredErrorMessage, this.UniqueID);
            switch (SubmitButtonType)
            {
                case ButtonType.Button:
                    helper.SetButton("SubmitButton", SubmitButtonText, this.UniqueID);
                    helper.SetVisible("SubmitButton", true);
                    break;

                case ButtonType.Image:
                    helper.SetImageButton("SubmitImageButton", SubmitButtonImageUrl, SubmitButtonText, this.UniqueID);
                    helper.SetVisible("SubmitImageButton", true);
                    break;

                case ButtonType.Link:
                    helper.SetButton("SubmitLinkButton", SubmitButtonText, this.UniqueID);
                    helper.SetVisible("SubmitLinkButton", true);
                    break;
            }

            //QuestionTemplate
            helper = new TemplateHelper(_ctlPasswordRecovery.QuestionTemplateContainer);
            helper.SetText("QuestionInstruction", QuestionInstructionText);
            helper.SetText("UserNameLabel", UserNameLabelText);
            helper.SetText("QuestionLabel", QuestionLabelText);
            helper.SetText("QuestionTitle", QuestionTitleText);
            helper.SetValidation("AnswerRequired", AnswerRequiredErrorMessage, this.UniqueID);
            switch (SubmitButtonType)
            {
                case ButtonType.Button:
                    helper.SetButton("SubmitButton", SubmitButtonText, this.UniqueID);
                    helper.SetVisible("SubmitButton", true);
                    break;

                case ButtonType.Image:
                    helper.SetImageButton("SubmitImageButton", SubmitButtonImageUrl, SubmitButtonText, this.UniqueID);
                    helper.SetVisible("SubmitImageButton", true);
                    break;

                case ButtonType.Link:
                    helper.SetButton("SubmitLinkButton", SubmitButtonText, this.UniqueID);
                    helper.SetVisible("SubmitLinkButton", true);
                    break;
            }

            //SuccessTemplate
            helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer);
            helper.SetText("Success", SuccessText);

            this.Controls.Add(_ctlPasswordRecovery);
        }