Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
4.17k stars 560 forks source link

Transfer All User Properties and Device Groups to a Different User #6449

Open rodrigolzd opened 1 week ago

rodrigolzd commented 1 week ago

Is your feature request related to a problem? Please describe. We recently lost a colleague who created and managed several device groups in the system. Now, all those groups are still tied to his account, which makes things a bit awkward since his name still shows up in the group details. We need to remove his user, but we don’t want to lose all the work he did.

Describe the solution you'd like It would be really helpful if there was a way to transfer all the properties tied to his account, especially device groups, to another user in one go. This would let us clean up the system without manually reassigning everything one by one.

Describe alternatives you've considered We’ve thought about manually moving each group and property, but that’s going to be pretty time-consuming given how many there are. Ideally, we'd like a bulk transfer option to make this smoother.

Additional context The goal is to make sure the groups remain intact, just under a new user, so we can safely delete the old account without any disruption.

Thanks for looking into this! Rodrigo

si458 commented 1 week ago

so sorry to hear about your loss! ive had a quick look into this and ive tested with my test server, you can achieve this by changing things in the database and i can walk you through it if you are happy to give thing a try? but ideally a button saying 'TRANSFER OWNERSHIP' does indeed sound like a good idea!

rodrigolzd commented 1 week ago

I'll do what we need to. I might be delayed on testing as i'm in a different timezone (São Paulo, Brazil), But I'll do my best to get back to you as fast as I can

TIA, Rodrigo.

si458 commented 1 week ago

@rodrigolzd sure no worries!

If you want u can email myself (check my github profile page)

And we can arrange a time to do the test and see if it works!

smartekIT commented 1 week ago

Hi guys, I remember I had to deal with the db in the past to change user details. here what I used. @si458 please let me know if I didn't remember exactly the right query, but I kind of remember it was:

### list all users:
db.getCollection("meshcentral").find({"_id" : /.*user.*/i}).limit(1000).skip(0);

OR

db.meshcentral.find({"_id" : /.*user.*/i}).limit(1000).skip(0);

### update username, user email, user real name:
db.meshcentral.update(
   { _id: "user//OLD_USERNAME" },
   {
     $set: {
       _id: "user//NEW_USERNAME",
       name: "NEW_NAME",
       email: "NEW_EMAIL",
       realname: "NEW_REALNAME"
     }
   }
)
si458 commented 1 week ago

@smartekIT that won't work because if u delete the user, any groups created by that user gets deleted as far as im aware

So the way I did it was replace the creator of the group, then add the group into ur links but give u the full rights instead,

smartekIT commented 1 week ago

also when run the query to list all users, if the same user found in _id field with value "wsuser//OLD_USERNAME" then we have to update that as well with the following query:

db.meshcentral.update(
   { _id: "wsuser//OLD_USERNAME" },
   {
     $set: {
       _id: "wsuser//NEW_USERNAME"
     }
   }
)

@si458 I thought my code is replacing, it's never deleting! Was following the guide here: https://www.mongodb.com/docs/manual/reference/method/db.collection.update/

si458 commented 1 week ago

@smartekIT I don't no i will have to try it! Thank u for the help though! I also don't know what database @rodrigolzd is using! So it's all learning

smartekIT commented 1 week ago

basically I'm updating/replacing the existing user details while keeping it's other properties like devices and groups or any other user settings.. etc.

Yeah champion I'm learning it and loving it. mongodb is a new world for me but it's very interesting db to work with and learn.

smartekIT commented 1 week ago

I use this windows application to work with mongodb and it's very clean GUI and nice and easy to work with: https://www.navicat.com/en/products/navicat-for-mongodb I highly recommend it.

si458 commented 1 week ago

@smartekIT mongodb compass i use its a nice little app and free hehe https://www.mongodb.com/products/tools/compass

smartekIT commented 1 week ago

here is an interested one which is open source and running as a docker, I never used it but looking at the features it's promising: https://github.com/anasjaber/mongo-explorer