///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// private Collection <string> SetPropertyValuesWeb(SettingsPropertyValueCollection values, bool cacheIsMoreFresh) { bool anyFailures = false; Collection <string> errorList = null; ClientFormsIdentity id = Thread.CurrentPrincipal.Identity as ClientFormsIdentity; try { errorList = SetPropertyValuesWebCore(values, cacheIsMoreFresh); anyFailures = (errorList != null && errorList.Count > 0); } catch (WebException) { if (id == null || _HonorCookieExpiry) { throw; } anyFailures = true; } if (!_HonorCookieExpiry && anyFailures) { // if there were failures, try re-validating the ClientFormsIdentity // and try again if (id != null) { id.RevalidateUser(); errorList = SetPropertyValuesWebCore(values, cacheIsMoreFresh); } } return(errorList); }
/// <summary> /// Login the user using the given username and password. If the username and password /// are the empty string, the login dialog box is displayed. /// </summary> /// <param name="userName">Username for login</param> /// <param name="password">Password for login</param> /// <returns>True if the user can be logged in</returns> public bool Login(string userName, string password) { bool isAuthorized = false; try { // Call ValidateUser with empty strings in order to display the // login dialog box configured as a credentials provider. isAuthorized = Membership.ValidateUser(userName, password); if (isAuthorized) { ClientFormsIdentity ci = Thread.CurrentPrincipal.Identity as ClientFormsIdentity; if (ci != null) { IsFormsAuthenticated = ci.IsAuthenticated; Name = ci.Name; } } } catch (Exception ex) { throw new Exception("Unable to Login", ex); } return(isAuthorized); }
///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// private void GetPropertyValuesFromWeb() { GetPropertyValuesFromWebCore(_HonorCookieExpiry); // Any failures? bool anyFailures = (_PropertyValues.Count < _Properties.Count); if (!_HonorCookieExpiry && anyFailures) { // if there were failures, try re-validating the ClientFormsIdentity // and try again ClientFormsIdentity id = Thread.CurrentPrincipal.Identity as ClientFormsIdentity; if (id != null) { id.RevalidateUser(); GetPropertyValuesFromWebCore(true); } } }