Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rodrigolzd opened this issue Oct 14, 2024 · 11 comments
Open

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

rodrigolzd opened this issue Oct 14, 2024 · 11 comments

Comments

@rodrigolzd
Copy link

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
Copy link
Collaborator

si458 commented Oct 15, 2024

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
Copy link
Author

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
Copy link
Collaborator

si458 commented Oct 15, 2024

@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
Copy link
Contributor

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
Copy link
Collaborator

si458 commented Oct 15, 2024

@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
Copy link
Contributor

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
Copy link
Collaborator

si458 commented Oct 15, 2024

@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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Collaborator

si458 commented Oct 15, 2024

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

@smartekIT
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants