/// <summary>
        /// Takes, as input, a user name and a role name and determines whether the specified user
        /// is associated with the specified role.
        /// </summary>
        /// <remarks>
        /// This is the main implementation for the <c>IsUserInRole</c> method of the provider. Please
        /// see the corresponding method in the Facade, which calls this method, for full documentaion.
        /// </remarks>
        /// <param name="username">The username that we wish to check.</param>
        /// <param name="roleName">The role which we wish to check.</param>
        /// <returns>Whether the given user is in the given role.</returns>
        internal bool IsUserInRole(string username, string roleName)
        {
            ValidationUtil.CheckParameterIsOK(ref roleName, true, true, true, 256, "roleName");
            ValidationUtil.CheckParameterIsOK(ref username, true, false, true, 256, "username");

            if (username.Length < 1)
            {
                return(false);
            }

            if (!this.UserExists(username))
            {
                throw new ProviderException(string.Format(Messages.UserNotFound));
            }

            if (!this.RoleExists(roleName))
            {
                throw new ProviderException(string.Format(Messages.RoleNotFound, roleName));
            }

            // ensure that we have an appication id
            if (this.ApplicationId == null)
            {
                throw new ArgumentNullException("ApplicationId");
            }

            // Instantiate a bool for whether the user is in the role - assume not.
            bool userIsInRole = false;

            // Build up the SQL string
            string sql = @"
                            SELECT 
                                COUNT(*) 
                            FROM 
                                aspnet_UsersInRoles
                            WHERE 
                                UserId = ? 
                            AND RoleId = ? 
                         ";

            // Create a new command and enrol in the current transaction.
            IngresCommand cmd = new IngresCommand(sql, this.conn);

            cmd.Transaction    = this.tran;
            cmd.CommandTimeout = this.config.CommandTimeout;

            // Get the user and role id's for the specified user and role names.
            string userid = this.GetUserIdByName(username);
            string roleid = this.GetRoleIdByName(roleName);

            cmd.Parameters.Add("UserId", DbType.String).Value = userid;
            cmd.Parameters.Add("RoleId", DbType.String).Value = roleid;

            // Execute the query and determine is the user is in the role.
            int rows = Convert.ToInt32(cmd.ExecuteScalar());

            if (rows > 0)
            {
                userIsInRole = true;
            }

            return(userIsInRole);
        }