diff --git a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Code/Utils.cs b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Code/Utils.cs index 4fb6e78..7089b19 100644 --- a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Code/Utils.cs +++ b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Code/Utils.cs @@ -198,12 +198,24 @@ public static string GetWebProperty(string key, string defaultValue) public static bool GetSiteProperty(string key, bool defaultValue) { - return Boolean.Parse(GetWebProperty(key, defaultValue.ToString(), SPContext.Current.Site.RootWeb)); + return GetSiteProperty(key, defaultValue, SPContext.Current.Site); } public static bool GetSiteProperty(string key, bool defaultValue, SPSite site) { - return Boolean.Parse(GetWebProperty(key, defaultValue.ToString(), site.RootWeb)); + bool result = defaultValue; + + SPSecurity.RunWithElevatedPrivileges(delegate() + { + using (SPSite privSite = new SPSite(site.ID, site.Zone)) + { + using (SPWeb web = privSite.RootWeb) + { + result = Boolean.Parse(GetWebProperty(key, defaultValue.ToString(), web)); + } + } + }); + return result; } public static void SetWebProperty(string key, string value, SPWeb web) diff --git a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/MembershipRequestWebPart/MembershipRequestControl.cs b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/MembershipRequestWebPart/MembershipRequestControl.cs index 4803d48..d783496 100644 --- a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/MembershipRequestWebPart/MembershipRequestControl.cs +++ b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/MembershipRequestWebPart/MembershipRequestControl.cs @@ -147,6 +147,8 @@ protected override void OnCreatingUser(LoginCancelEventArgs e) request.LastName = this.LastName; request.DefaultGroup = this._DefaultGroup; request.LoginCreatedUser = false; + request.SiteName = web.Title; + request.SiteURL = web.Url; if (!MembershipRequest.CopyToReviewList(request)) { lblError.Text = this.UnknownErrorMessage; diff --git a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/PasswordRecoveryWebPart/PasswordRecoveryWebPart.cs b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/PasswordRecoveryWebPart/PasswordRecoveryWebPart.cs index 124a0a8..392dd50 100644 --- a/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/PasswordRecoveryWebPart/PasswordRecoveryWebPart.cs +++ b/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/PasswordRecoveryWebPart/PasswordRecoveryWebPart.cs @@ -426,34 +426,31 @@ void _ctlPasswordRecovery_VerifyingUser(object sender, LoginCancelEventArgs e) void _ctlPasswordRecovery_SendMailError(object sender, SendMailErrorEventArgs e) { - using (SPSite _site = new SPSite(SPContext.Current.Site.ID, SPContext.Current.Site.Zone)) + SPWeb _web = SPContext.Current.Web; + + PasswordRecovery prc = (PasswordRecovery)sender; + MembershipUser currentUser = Utils.BaseMembershipProvider(_web.Site).GetUser(prc.UserName, false); + MembershipRequest membershipitem = new MembershipRequest(); + membershipitem.UserEmail = currentUser.Email; + membershipitem.UserName = currentUser.UserName; + membershipitem.SiteName = _web.Title; + membershipitem.SiteURL = _web.Url; + membershipitem.PasswordQuestion = currentUser.PasswordQuestion; + membershipitem.Password = currentUser.ResetPassword(prc.Answer); + + /* These are the possible set of URLs that are provided to the user and developer in the XSLT */ + MembershipSettings settings = new MembershipSettings(_web); + membershipitem.ChangePasswordURL = Utils.GetAbsoluteURL(_web, settings.ChangePasswordPage); + membershipitem.PasswordQuestionURL = Utils.GetAbsoluteURL(_web, settings.PasswordQuestionPage); + membershipitem.ThankYouURL = Utils.GetAbsoluteURL(_web, settings.ThankYouPage); + + if (!MembershipRequest.SendPasswordResetEmail(membershipitem, _web)) { - using (SPWeb _web = _site.OpenWeb()) - { - PasswordRecovery prc = (PasswordRecovery)sender; - MembershipUser currentUser = Utils.BaseMembershipProvider(_web.Site).GetUser(prc.UserName, false); - MembershipRequest membershipitem = new MembershipRequest(); - membershipitem.UserEmail = currentUser.Email; - membershipitem.UserName = currentUser.UserName; - membershipitem.SiteName = _web.Title; - membershipitem.SiteURL = _web.Url; - membershipitem.PasswordQuestion = currentUser.PasswordQuestion; - membershipitem.Password = currentUser.ResetPassword(prc.Answer); - - /* These are the possible set of URLs that are provided to the user and developer in the XSLT */ - MembershipSettings settings = new MembershipSettings(_web); - membershipitem.ChangePasswordURL = Utils.GetAbsoluteURL(_web, settings.ChangePasswordPage); - membershipitem.PasswordQuestionURL = Utils.GetAbsoluteURL(_web, settings.PasswordQuestionPage); - membershipitem.ThankYouURL = Utils.GetAbsoluteURL(_web, settings.ThankYouPage); - - if (!MembershipRequest.SendPasswordResetEmail(membershipitem, _web)) - { - TemplateHelper helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer); - helper.SetText("Success", LocalizedString.GetString("FBAPackPasswordRecoveryWebPart", "ErrorSendingEmail")); - } - e.Handled = true; - } + TemplateHelper helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer); + helper.SetText("Success", LocalizedString.GetString("FBAPackPasswordRecoveryWebPart", "ErrorSendingEmail")); } + e.Handled = true; + } protected override void CreateChildControls()