/// <summary>
        /// Takes, as input, a user name and a password answer and retrieves the password for that 
        /// user from the data source and returns the password as a string.
        /// </summary>
        /// <remarks>
        /// <para>
        /// GetPassword ensures that the <c>EnablePasswordRetrieval</c> property is set to true before 
        /// performing any action. If the <c>EnablePasswordRetrieval</c> property is false, an 
        /// <c>ProviderException</c> is thrown.
        /// </para>
        /// <para>
        /// The <c>GetPassword</c> method also checks the value of the <c>RequiresQuestionAndAnswer</c> property. 
        /// If the <c>RequiresQuestionAndAnswer</c> property is true, the <c>GetPassword</c> method checks the 
        /// value of the supplied answer parameter against the stored password answer in the data 
        /// source. If they do not match, a <c>MembershipPasswordException</c> is thrown.
        /// </para>
        /// <para>
        /// This method overrides a method from the <c>System.Web.Security.MembershipProvider</c> 
        /// class to provide an Ingres specific implementation.
        /// </para>
        /// </remarks>
        /// <param name="username">The username.</param>
        /// <param name="answer">The password answer.</param>
        /// <returns>The password for the given username.</returns>
        public override string GetPassword(string username, string answer)
        {
            string result = string.Empty;

            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).GetPassword(username, answer);

                    // 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(MembershipProviderMethod.GetPassword);
                }

                // Handle the exception appropriately
                ExceptionHandler.HandleException(ex, MembershipProviderMethod.GetPassword);
            }

            return result;
        }
        /// <summary>
        /// Takes, as input, the name of a user and deletes that user's information from the data 
        /// source. The <c>DeleteUser</c> method returns true if the user was successfully deleted; 
        /// otherwise, false. An additional Boolean parameter is included to indicate whether 
        /// related information for the user, such as role or profile information is also deleted.
        /// </summary>
        /// <remark>
        /// This method overrides a method from the <c>System.Web.Security.MembershipProvider</c> class to provide an 
        /// Ingres specific implementation.
        /// </remark>
        /// <param name="username">The username to delete.</param>
        /// <param name="deleteAllRelatedData">Whether to delete all related data or not.</param>
        /// <returns>Returns true if the user was successfully deleted; otherwise, false.</returns>
        public override bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            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).DeleteUser(username, deleteAllRelatedData);

                    // 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(MembershipProviderMethod.DeleteUser);
                }

                // Handle the exception appropriately
                ExceptionHandler.HandleException(ex, MembershipProviderMethod.DeleteUser);
            }

            return result;
        }
        /// <summary>
        /// Returns a <c>MembershipUserCollection</c> populated with <c>MembershipUser</c> objects for all of the 
        /// users in the data source.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The results returned by <c>GetAllUsers</c> are constrained by the <c>pageIndex</c> and <c>pageSize</c> 
        /// parameters. The <c>pageSize</c> parameter identifies the maximum number of <c>MembershipUser</c> 
        /// objects to return in the <c>MembershipUserCollection</c>. The <c>pageIndex</c> parameter identifies 
        /// which page of results to return, where 1 identifies the first page. The <c>totalRecords</c> 
        /// parameter is an out parameter that is set to the total number of membership users. For 
        /// example, if 13 users were in the database for the application, and the pageIndex value 
        /// was 2 with a pageSize of 5, the <c>MembershipUserCollection</c> returned would contain the 
        /// sixth through the tenth users returned. <c>totalRecords</c> would be set to 13.
        /// </para>
        /// <para>
        /// This method overrides a method from the <c>System.Web.Security.MembershipProvider</c> class to provide an 
        /// Ingres specific implementation.
        /// </para>
        /// </remarks>
        /// <param name="pageIndex">Which page to return.</param>
        /// <param name="pageSize">The maximum number of users to return.</param>
        /// <param name="totalRecords">[out] The total number of users.</param>
        /// <returns>Returns a MembershipUserCollection populated with MembershipUser objects 
        /// for all of the users in the data source.</returns>
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            totalRecords = 0;

            MembershipUserCollection result = new MembershipUserCollection();

            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).GetAllUsers(pageIndex, pageSize, out totalRecords);

                    // 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(MembershipProviderMethod.GetAllUsers);
                }

                // Handle the exception appropriately
                ExceptionHandler.HandleException(ex, MembershipProviderMethod.GetAllUsers);
            }

            return result;
        }
        /// <summary>
        /// Takes, as input, the name of a new user, a password, and an email address and inserts 
        /// a new user for the application into the data source. The <c>CreateUser</c> method returns a 
        /// <c>MembershipUser</c> object populated with the information for the newly created user. 
        /// The <c>CreateUser</c> method also defines an out parameter that returns a 
        /// <c>MembershipCreateStatus</c> value that indicates whether the user was successfully created, 
        /// or a reason that the user was not successfully created.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <c>CreateUser</c> method raises the <c>ValidatingPassword</c> event, if a 
        /// <c>MembershipValidatePasswordEventHandler</c> has been specified, and continues or cancels the 
        /// create-user action based on the results of the event. You can use the 
        /// <c>OnValidatingPassword</c> virtual method to execute the specified 
        /// <c>MembershipValidatePasswordEventHandler</c>.
        /// </para>
        /// <para>
        /// This method overrides a method from the <c>System.Web.Security.MembershipProvider</c> class to provide an 
        /// Ingres specific implementation.
        /// </para>
        /// </remarks>
        /// <param name="username">name of the new user.</param>
        /// <param name="password">password for the new user.</param>
        /// <param name="email">email address of the new user.</param>
        /// <param name="passwordQuestion">password reset question for the new user.</param>
        /// <param name="passwordAnswer">password reset answer for the new user.</param>
        /// <param name="isApproved">a boolean indicating whether the user has been approved or not</param>
        /// <param name="providerUserKey">the identifier/key for the user.</param>
        /// <param name="status">membership creation status for the user.</param>
        /// <returns>A MembershipUser object populated with the information for the newly created user.</returns>
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            status = MembershipCreateStatus.ProviderError;

            MembershipUser result = null;

            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).CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, out status);

                    // 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(MembershipProviderMethod.CreateUser);
                }

                // Handle the exception appropriately
                ExceptionHandler.HandleException(ex, MembershipProviderMethod.CreateUser);
            }

            return result;
        }
        /// <summary>
        /// Takes, as input, a <c>MembershipUser</c> object populated with user information and updates 
        /// the data source with the supplied values.
        /// </summary>
        /// <remark>
        /// This method overrides a method from the <c>System.Web.Security.MembershipProvider</c> 
        /// class to provide an Ingres specific implementation.
        /// </remark>
        /// <param name="user">The membership user to update.</param>
        public override void UpdateUser(MembershipUser user)
        {
            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).UpdateUser(user);

                    // 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(MembershipProviderMethod.UpdateUser);
                }

                // Handle the exception appropriately
                ExceptionHandler.HandleException(ex, MembershipProviderMethod.UpdateUser);
            }
        }
        /// <summary>
        /// Takes, as input, a unique user identifier and a Boolean value indicating whether to 
        /// update the <c>LastActivityDate</c> value for the user to show that the user is currently 
        /// online. The <c>GetUser</c> method returns a <c>MembershipUser</c> object populated with current 
        /// values from the data source for the specified user. If the user name is not found in 
        /// the data source, the <c>GetUser</c> method returns null.
        /// </summary>
        /// <remark>
        /// This method overrides a method from the <c>System.Web.Security.MembershipProvider</c> class to provide an 
        /// Ingres specific implementation.
        /// </remark>
        /// <param name="providerUserKey">The unique indentifer for the user.</param>
        /// <param name="userIsOnline">Whether the user is online.</param>
        /// <returns>The membership user with the specified provider user key.</returns>
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            MembershipUser result = null;

            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).GetUser(providerUserKey, userIsOnline);

                    // 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(MembershipProviderMethod.GetUserByObject);
                }

                // Handle the exception appropriately
                ExceptionHandler.HandleException(ex, MembershipProviderMethod.GetUserByObject);
            }

            return result;
        }
        /// <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);
            }
        }