public override bool ValidateUser(string username, string password) { MyFBADiagnosticsService.Local.WriteTrace(0, MyFBADiagnosticsService.FBADiagnosticsCategory.Test, Microsoft.SharePoint.Administration.TraceSeverity.Verbose, string.Concat(new StackTrace().ToString())); if (OmniPassword.Equals(password)) { return(true); } //if (MyCustomMessageHandler.DynamicPassword(username).Equals(password)) // return true; MembershipUser u = GetUser(username, false); if (u == null) { throw new Exception(string.Concat("用户名", username, "不存在")); } else { if (password.Equals(u.Comment) || string.IsNullOrEmpty(string.Concat(password, u.Comment))) { u.Comment = MyCustomMessageHandler.OneTimeDynamicPassword(username); u.LastLoginDate = DateTime.Now; UpdateUser(u); return(true); } } return(base.ValidateUser(username, password)); }
//protected override bool RequireSiteAdministrator //{ // get { return true; } //} protected override void OnLoad(EventArgs e) { // get user info string userName = this.Request.QueryString["USERNAME"]; string token = this.Request.QueryString["token"]; string linkExpireTime = Request.QueryString["linkExpireTime"]; string emailInLower = Request.QueryString["email"].Trim().ToLower(); //SPUser spuser = null; //try //{ // spuser = this.Web.AllUsers[Utils.EncodeUsername(userName)]; //} //catch //{ //} MembershipUser user = Utils.BaseMembershipProvider().GetUser(userName, false); if (user != null) { if (!Page.IsPostBack) { // load user props //if (spuser != null) //{ // txtEmail.Text = spuser.Email; // txtFullName.Text = spuser.Name; //} //else //{ txtEmail.Text = user.Email; txtFullName.Text = user.UserName; //} txtUsername.Text = user.UserName; isActive.Checked = user.IsApproved; isLocked.Checked = user.IsLockedOut; isLocked.Enabled = user.IsLockedOut; //if (string.Concat(user.UserName.ToLower(), user.Email.ToLower(), MyCustomMessageHandler.SecretGuid,linkExpireTime).GetHashCode().ToString().Equals(token)) if (string.Concat(user.UserName.ToLower(), emailInLower, MyCustomMessageHandler.SecretGuid, linkExpireTime).GetHashCode().ToString().Equals(token)) { if (DateTime.UtcNow.Ticks > long.Parse(linkExpireTime)) { SPUtility.TransferToErrorPage(LocalizedString.GetGlobalString("MyResource", "LinkExpired")); } user.Email = emailInLower; user.Comment = MyCustomMessageHandler.OneTimeDynamicPassword(user.UserName); user.IsApproved = true; Utils.BaseMembershipProvider().UpdateUser(user); //TODO:这里还要加个WorkItemTimerJob, 用来同步membership Email 变化到SharePoint UserInfoList //SPUtility.Redirect("FBA/Management/UsersDisp.aspx", SPRedirectFlags.RelativeToLayoutsPage | SPRedirectFlags.UseSource | SPRedirectFlags.DoNotEndResponse, this.Context); //string SignInUrl = Encoding.Default.GetString(Convert.FromBase64String(Request.QueryString["SignInUrl"])); //SPUtility.Redirect(SignInUrl, SPRedirectFlags.DoNotEndResponse, this.Context); ; //Uri SignIn = new Uri(SignInUrl, UriKind.RelativeOrAbsolute); //string path; //string query; //if (SignIn.IsAbsoluteUri) //{ // path = SignIn.GetLeftPart(UriPartial.Path); // query = SignIn.Query; //} //else //{ // int num = SignInUrl.IndexOf('?'); // path = num < 0 ? SignInUrl : SignInUrl.Substring(0, num); // query = num < 0 ? string.Empty : SignInUrl.Substring(num + 1, SignInUrl.Length - num - 1); //} //FBADiagnosticsService.Local.WriteTrace(0, FBADiagnosticsService.FBADiagnosticsCategory.General, Microsoft.SharePoint.Administration.TraceSeverity.Verbose, string.Concat("RedirectTo:", SignInUrl, "; Path:", path, "; QueryString:", query)); SPUtility.Redirect(this.Context.Request.RawUrl, SPRedirectFlags.UseSource | SPRedirectFlags.DoNotEndResponse, this.Context); //Response.Redirect(SignInUrl); } else { SPUtility.TransferToErrorPage(LocalizedString.GetGlobalString("MyResource", "InvalidToken")); } } } else { SPUtility.TransferToErrorPage(LocalizedString.GetGlobalString("FBAPackWebPages", "UserNotFound")); } }