public void Dispose() { if (_db != null) { _db.Dispose(); } }
public virtual ActionResult KillSession(UserSession model) { OracleDatastore db = null; try { db = new OracleDatastore(this.HttpContext.Trace); DbConnectionStringBuilder dcms8 = new DbConnectionStringBuilder(); dcms8.ConnectionString = ConfigurationManager.ConnectionStrings["dcms8"].ConnectionString; // Creating the connection as super user db.CreateConnection(dcms8.ConnectionString, string.Empty); const string QUERY_ALTER_USER = "******"; var sql = string.Format(QUERY_ALTER_USER, model.SessionId, model.SerialNumber); db.ExecuteNonQuery(sql, null); AddStatusMessage(string.Format("Session of user {0} kill successfully", model.UserName)); } catch (ProviderException ex) { ModelState.AddModelError("", ex.Message); } finally { if (db != null) { db.Dispose(); } } return(RedirectToAction(Actions.ManageUser(model.UserName))); }
/// <summary> /// Returns true if we are able to successfully connect to oracle using the supplied username and password. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <exception cref="System.Web.Security.MembershipPasswordException">Password has expired and needs to be changed before login can be allowed</exception> /// <returns></returns> public override bool ValidateUser(string username, string password) { var builder = new OracleConnectionStringBuilder(_connectionString) { UserID = username, Password = password, Pooling = false, ProxyUserId = string.Empty, ProxyPassword = string.Empty }; OracleDatastore db = null; try { db = new OracleDatastore(HttpContext.Current.Trace); db.CreateConnection(builder.ConnectionString, string.Empty); db.Connection.Open(); return(true); } catch (OracleException ex) { // Connection could not be opened Trace.TraceWarning(ex.Message); switch (ex.Number) { case 1017: // Invalid user name password Trace.TraceWarning("Invalid password specified for user {0}", username); return(false); case 28001: // Password expired throw new MembershipPasswordException("Password has expired. Please change your password and try again.", ex); default: throw; } } finally { // For clearing the cached roles of the user. OracleRoleProvider orp = Roles.Providers.OfType <OracleRoleProvider>().SingleOrDefault(); if (orp != null) { orp.ClearRoleCache(username); } if (db != null) { db.Dispose(); } } }
public virtual ActionResult LockedUser(ManageUserViewModel model) { if (string.IsNullOrWhiteSpace(model.User.UserName)) { throw new ArgumentNullException("userName"); } OracleDatastore db = null; try { db = new OracleDatastore(this.HttpContext.Trace); DbConnectionStringBuilder dcms8 = new DbConnectionStringBuilder(); dcms8.ConnectionString = ConfigurationManager.ConnectionStrings["dcms8"].ConnectionString; // Creating the connection as super user db.CreateConnection(dcms8.ConnectionString, string.Empty); const string QUERY_ALTER_USER = "******"; var sql = string.Format(QUERY_ALTER_USER, model.User.UserName); db.ExecuteNonQuery(sql, null); AddStatusMessage(string.Format("{0} user account has been locked", model.User.UserName)); } catch (ProviderException ex) { ModelState.AddModelError("", ex.Message); } finally { if (db != null) { db.Dispose(); } } return(RedirectToAction(Actions.ManageUser(model.User.UserName))); }
/// <summary> /// Returns true if we are able to successfully connect to oracle using the supplied username and password. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <exception cref="System.Web.Security.MembershipPasswordException">Password has expired and needs to be changed before login can be allowed</exception> /// <returns></returns> public override bool ValidateUser(string username, string password) { var builder = new OracleConnectionStringBuilder(_connectionString) { UserID = username, Password = password, Pooling = false, ProxyUserId = string.Empty, ProxyPassword = string.Empty }; OracleDatastore db = null; try { db = new OracleDatastore(HttpContext.Current.Trace); db.CreateConnection(builder.ConnectionString, string.Empty); db.Connection.Open(); return true; } catch (OracleException ex) { // Connection could not be opened Trace.TraceWarning(ex.Message); switch (ex.Number) { case 1017: // Invalid user name password Trace.TraceWarning("Invalid password specified for user {0}", username); return false; case 28001: // Password expired throw new MembershipPasswordException("Password has expired. Please change your password and try again.", ex); default: throw; } } finally { // For clearing the cached roles of the user. OracleRoleProvider orp = Roles.Providers.OfType<OracleRoleProvider>().SingleOrDefault(); if (orp != null) { orp.ClearRoleCache(username); } if (db != null) { db.Dispose(); } } }
public void Dispose() { _db.Dispose(); }