DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

DNN For YAF Uninstalled & Can't Delete Users Now

 2 Replies
 2 Subscribed to this topic
 23 Subscribed to this forum
Sort:
Author
Messages
Senior Member
Posts: 1425
Senior Member

    Hey Everyone: 

    If you're running or know DNN for YAF, I have this pressing issue that I need a bit of help with.  Thanks in advance!  :)  

    https://yetanotherforum.n...elete-Superusers-Now

    Veteran Member
    Posts: 1178
    Veteran Member
      Will,

      I had the same problem a while ago, and I don't remember exactly what it was (and unfortunately I did not document it anywhere) - but I think that YAF modified one of the DNN Stored procedures (RemoveUser?), and deleting this procedure and re-creating it from the original DNN script did the trick.

      Hope that helps...

      Happy DNNing!
      Michael

      Michael Tobisch
      DNN★MVP

      DNN Connect
      Senior Member
      Posts: 1425
      Senior Member

        Aha!  I should've thought to search through the sprocs.  You were correct about this.  The RemoveUsers procedure was modified.  This is a core code change.  Had I known this was happening, I wouldn't have ever even tried using this module.  :(  

        It was the only sproc that had the term yaf in it.  I used these queries to find it: 

        SELECT OBJECT_NAME(object_id)
            FROM sys.sql_modules
            WHERE OBJECTPROPERTY(object_id, 'IsProcedure') = 1
            AND definition LIKE '%yaf%'

        SELECT OBJECT_NAME(id) 
            FROM SYSCOMMENTS 
            WHERE [text] LIKE '%yaf%' 
            AND OBJECTPROPERTY(id, 'IsProcedure') = 1 
            GROUP BY OBJECT_NAME(id)

        SELECT ROUTINE_NAME, ROUTINE_DEFINITION
            FROM INFORMATION_SCHEMA.ROUTINES 
            WHERE ROUTINE_DEFINITION LIKE '%yaf%' 
            AND ROUTINE_TYPE='PROCEDURE'

        I used a clean instance of DNN 9.12 (same version) to drop and recreate the sproc: 

        /****** Object:  StoredProcedure [dbo].[RemoveUser]    Script Date: 8/31/2023 9:07:40 AM ******/
        DROP PROCEDURE [dbo].[RemoveUser]
        GO

        /****** Object:  StoredProcedure [dbo].[RemoveUser]    Script Date: 8/31/2023 9:07:40 AM ******/
        SET ANSI_NULLS ON
        GO

        SET QUOTED_IDENTIFIER ON
        GO

        CREATE PROCEDURE [dbo].[RemoveUser]
            @UserID        int,
            @PortalID   int
        AS
            IF @PortalID IS NULL
                BEGIN
                    -- Delete SuperUser
                    DELETE FROM dbo.Users
                        WHERE  UserId = @UserID
                END
            ELSE
                BEGIN
                    -- Remove User from Portal
                    DELETE FROM dbo.UserPortals
                        WHERE  UserId = @UserID
                         AND PortalId = @PortalID
                    IF NOT EXISTS (SELECT 1 FROM dbo.UserPortals WHERE  UserId = @UserID)
                        -- Delete User (but not if SuperUser)
                        BEGIN
                            DELETE FROM dbo.Users
                                WHERE  UserId = @UserID
                                    AND IsSuperUser = 0
                            DELETE FROM dbo.UserRoles
                                WHERE  UserID = @UserID
                        END
                    ELSE
                        BEGIN
                            DELETE ur FROM dbo.UserRoles ur
                                INNER JOIN dbo.Roles r ON r.RoleID = ur.RoleID
                                WHERE  UserID = @UserID AND r.PortalID = @PortalID
                        END
                END
        GO

        These are superusers I'm attempting to permanently remove, so far.  They're already marked as deleted, but I still can't use the option in the Users view to "Permanently Delete."  I get a new error, listed below.  However, an interesting thing to note is that running the purge- user prompt command doesn't display any error at all.  If I took that for it's word, the same user accounts I'm trying to delete are deleted, but they're still there.  

        ERROR MESSAGE

        Message:Internal Query Processor Error: The query processor encountered an unexpected error during execution (HRESULT = 0x80040e19).

        StackTrace:

           at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
           at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
           at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
           at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
           at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
           at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
           at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
           at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
           at PetaPoco.Database.<>c.b__353_0(IDbCommand c)
           at PetaPoco.Database.CommandHelper(IDbCommand cmd, Func`2 cmdFunc)
           at PetaPoco.Database.ExecuteNonQueryHelper(IDbCommand cmd)
           at PetaPoco.Database.ExecuteInternal(CommandType commandType, String sql, Object[] args)
           at DotNetNuke.Data.PetaPoco.PetaPocoHelper.ExecuteNonQuery(String connectionString, CommandType type, Int32 timeoutSec, String sql, Object[] args)
           at DotNetNuke.Data.SqlDataProvider.ExecuteNonQuery(String procedureName, Object[] commandParameters)
           at DotNetNuke.Security.Membership.AspNetMembershipProvider.RemoveUser(UserInfo user)

        This means that there are likely MORE core code changes that were made.  Ugh... 

        These Forums are dedicated to the discussion of DNN Platform.

        For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

        1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
        2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
        3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
        4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
        5. No Flaming or Trolling.
        6. No Profanity, Racism, or Prejudice.
        7. Site Moderators have the final word on approving / removing a thread or post or comment.
        8. English language posting only, please.

        Would you like to help us?

        Awesome! Simply post in the forums using the link below and we'll get you started.

        Get Involved