DNN Forums

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

Delete users programmatically

Sort:
You are not authorized to post a reply.
Page 1 of 212 > >>





Growing Member





    Hello,
    deleting all users by the method

    UserController.DeleteUsers(int portalId, bool notify, bool deleteAdmin)

    ,

    I ran into this error:



    System.NullReferenceException: Object reference not set to an instance of an object.
       at DotNetNuke.Entities.Users.UserController.UpdateUser(Int32 portalId, UserInfo user, Boolean loggedAction, Boolean sendNotification, Boolean clearCache) in C:\DNN\09.11.2\DNN Platform\Library\Entities\Users\UserController.cs:line 1917
       at DotNetNuke.Entities.Users.UserController.UpdateUser(Int32 portalId, UserInfo user, Boolean loggedAction, Boolean sendNotification) in C:\DNN\09.11.2\DNN Platform\Library\Entities\Users\UserController.cs:line 1275
       at DotNetNuke.Entities.Users.UserController.UpdateUser(Int32 portalId, UserInfo user, Boolean loggedAction) in C:\DNN\09.11.2\DNN Platform\Library\Entities\Users\UserController.cs:line 1265
       at DotNetNuke.Entities.Users.UserController.UpdateUser(Int32 portalId, UserInfo user) in C:\DNN\09.11.2\DNN Platform\Library\Entities\Users\UserController.cs:line 1256
       at DotNetNuke.Entities.Users.UserController.DeleteUser(UserInfo& user, Boolean notify, Boolean deleteAdmin) in C:\DNN\09.11.2\DNN Platform\Library\Entities\Users\UserController.cs:line 500
       at DotNetNuke.Entities.Users.UserController.DeleteUsers(Int32 portalId, Boolean notify, Boolean deleteAdmin) in C:\DNN\09.11.2\DNN Platform\Library\Entities\Users\UserController.cs:line 514


    The method

    UserInfo GetUserById(int portalId, int userId)

    return NULL executing this line of code:


    ...
    user = MembershipProvider.Instance().GetUser(GetEffectivePortalId(portalId), userId);
    ...


    I'm using AspNetMembershipProvider

    Scenario: I'm porting some modules developed for DNN 7.4 to DNN 9.11.2, and I noticed the call to

    UpdateUser(portalId, GetUserById(portalId, user.UserID))

    was added.

    Any idea on how to get around the problem?
    Thanks
    S.






    Advanced Member





      I don't have a quick resolution, but curious if you have portal groups setup?





      Veteran Member





        We have a module that deletes users, you can find the code here and it is working in DNN 9.11.2:

        https://github.com/40fing...rsController.cs#L228






        Growing Member





          Posted By Daniel Valadas on 2/1/2024 2:13 PM
          I don't have a quick resolution, but curious if you have portal groups setup?

          Hi Daniel,
          I've installed and configured only one portal, updating it from 7.4 using the recommended steps up to 9.11.2

           

           






          Growing Member





            Posted By Timo Breumelhof (40F) on 2/1/2024 5:20 PM

            We have a module that deletes users, you can find the code here and it is working in DNN 9.11.2:

            https://github.com/40fing...rsController.cs#L228

            Hi Timo,
            I've seen you are using UserController's API...have you never tested the DeleteUsers? :-\

             

             






            Advanced Member





              If you join our discord and attend one of our co-coding sessions, happy to try to pinpoint it with you.

              Alternatively, if you can do a minimal module that makes this bug happen, you could create an issue with it at https://github.com/dnnsof.../Dnn.Platform/issues which would make it easy to test/fix.





              Growing Member





                Posted By Daniel Valadas on 2/2/2024 3:13 AM
                If you join our discord and attend one of our co-coding sessions, happy to try to pinpoint it with you.

                Alternatively, if you can do a minimal module that makes this bug happen, you could create an issue with it at https://github.com/dnnsof.../Dnn.Platform/issues which would make it easy to test/fix.

                 

                Opened an issue on GitHub.
                Could you be more specific on "If you join our discord and attend one of our co-coding sessions, happy to try to pinpoint it with you."

                Thanks
                S.

                 






                Advanced Member





                  Discord is a messaging app and we do co-coding sessions (live audio/video streaming) almost every week to co-code and help people on anything open-source related to DNN. If you go to the home page of this very site, you will see near the bottom a panel with a button to join our discord. Once there you will see "Events" and you can see when the next ones occur and join them. It is a great way to look into more complex issues live.





                  Growing Member





                    Problem found, there is a trigger on the db that remove the record immediately :-|
                    Is there a setting at portale level to do that?

                    Thanks again





                    Advanced Member





                      Posted By Seek78 on 2/5/2024 1:39 PM
                      Problem found, there is a trigger on the db that remove the record immediately :-|
                      Is there a setting at portale level to do that?

                      Thanks again


                      I am unaware of any triggers in the DNN database by default.  So, this must have been added by someone.

                       

                      David Poindexter


                      Creator:


                      You are not authorized to post a reply.
                      Page 1 of 212 > >>

                      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