/// <summary> /// This method takes a role name and determines whether the role exists. /// </summary> /// <remarks> /// This method overrides a method from the <c>System.Web.Security.RoleProvider</c> class to provide an Ingres /// specific implementation. /// </remarks> /// <param name="roleName">Role name to check the existence of.</param> /// <returns>Whether the given role exists.</returns> public override bool RoleExists(string roleName) { bool result = false; IngresTransaction tran = null; try { using (IngresConnection conn = new IngresConnection(this.config.ConnectionString)) { // Open the connection and start a new transaction conn.Open(); tran = conn.BeginTransaction(); // Call the implementation of the method result = this.GetHandler(conn, tran).RoleExists(roleName); // Commit the transaction tran.Commit(); } } catch (Exception ex) { // Attempt to rollback try { if (tran != null && tran.Connection != null) { tran.Rollback(); } } catch { // Add the rollback error. ExceptionHandler.LogRollbackWarning(RoleProviderMethod.RoleExists); } // Handle the exception appropriately ExceptionHandler.HandleException(ex, RoleProviderMethod.RoleExists); } return(result); }
/// <summary> /// Takes an array of user names and an array of role names and removes the specified users /// from the specified roles. /// </summary> /// <remarks> /// <para> /// <c>RemoveUsersFromRoles</c> throws a <c>ProviderException</c> if any of the users or roles do not /// exist, or if any user specified in the call does not belong to the role from which he /// or she is being removed. /// </para> /// <para> /// This method overrides a method from the <c>System.Web.Security.RoleProvider</c> class to provide an Ingres /// specific implementation. /// </para> /// </remarks> /// <param name="usernames">The array of usernames.</param> /// <param name="roleNames">The array of roles.</param> public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { IngresTransaction tran = null; try { using (IngresConnection conn = new IngresConnection(this.config.ConnectionString)) { // Open the connection and start a new transaction conn.Open(); tran = conn.BeginTransaction(); // Call the implementation of the method this.GetHandler(conn, tran).RemoveUsersFromRoles(usernames, roleNames); // Commit the transaction tran.Commit(); } } catch (Exception ex) { // Attempt to rollback try { if (tran != null && tran.Connection != null) { tran.Rollback(); } } catch { // Add the rollback error. ExceptionHandler.LogRollbackWarning(RoleProviderMethod.RemoveUsersFromRoles); } // Handle the exception appropriately ExceptionHandler.HandleException(ex, RoleProviderMethod.RemoveUsersFromRoles); } }