[GH-ISSUE #293] Expose UUID Field #111

Closed
opened 2026-02-27 08:15:17 +03:00 by kerem · 21 comments
Owner

Originally created by @zicklag on GitHub (Aug 27, 2022).
Original GitHub issue: https://github.com/lldap/lldap/issues/293

Would you be open to exposing the uuid field for users and groups in the LDAP API?

I'm having an issue migrating my nextcloud instance to lldap because nextcloud uses the uuid field in order to map users to their Nextcloud equivalents. Essentially, once the user is created with a UUID, there's no way to map them to a new LDAP user, so I have no way to make Nextcloud respect the new accounts, even if they have the same DN, without there being a uuid field on the LDAP records.

If might be able to open a PR for this, but that's only if I don't find a work-around, because I'm quite busy, unfortunately.

Big thanks for LLDAP! ❤️

Originally created by @zicklag on GitHub (Aug 27, 2022). Original GitHub issue: https://github.com/lldap/lldap/issues/293 Would you be open to exposing the `uuid` field for users and groups in the LDAP API? I'm having an issue migrating my nextcloud instance to lldap because nextcloud uses the `uuid` field in order to map users to their Nextcloud equivalents. Essentially, once the user is created with a UUID, there's no way to map them to a new LDAP user, so I have no way to make Nextcloud respect the new accounts, even if they have the same DN, without there being a uuid field on the LDAP records. If might be able to open a PR for this, but that's only if I don't find a work-around, because I'm quite busy, unfortunately. Big thanks for LLDAP! ❤️
Author
Owner

@nitnelave commented on GitHub (Aug 27, 2022):

I guess it could make sense in the context of a migration to allow user
creation to specify a UUID. Not for user modification though.

I'd be open to a PR adding it to the GraphQL interface, and if it's not
given then it's generated automatically.
You'll need to add support to the frontend, and potentially the migration
tool as well. The migration tool should probably try a few different
alternative fields to find the UUID (entryUUID, ipaUuid, ...)

On Sat, 27 Aug 2022, 14:34 Zicklag, @.***> wrote:

Would you be open to exposing the uuid field for users and groups in the
LDAP API?

I'm having an issue migrating my nextcloud instance to lldap because
nextcloud uses the uuid field in order to map users to their Nextcloud
equivalents. Essentially, once the user is created with a UUID, there's no
way to map them to a new LDAP user, so I have no way to make Nextcloud
respect the new accounts, even if they have the same DN, without there
being a uuid field on the LDAP records.

If might be able to open a PR for this.


Reply to this email directly, view it on GitHub
https://github.com/nitnelave/lldap/issues/293, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAGCPWNZU4VITCEAT6FC3HLV3JUUHANCNFSM57ZZOUDA
.
You are receiving this because you are subscribed to this thread.Message
ID: @.***>

<!-- gh-comment-id:1229278288 --> @nitnelave commented on GitHub (Aug 27, 2022): I guess it could make sense in the context of a migration to allow user creation to specify a UUID. Not for user modification though. I'd be open to a PR adding it to the GraphQL interface, and if it's not given then it's generated automatically. You'll need to add support to the frontend, and potentially the migration tool as well. The migration tool should probably try a few different alternative fields to find the UUID (entryUUID, ipaUuid, ...) On Sat, 27 Aug 2022, 14:34 Zicklag, ***@***.***> wrote: > Would you be open to exposing the uuid field for users and groups in the > LDAP API? > > I'm having an issue migrating my nextcloud instance to lldap because > nextcloud uses the uuid field in order to map users to their Nextcloud > equivalents. Essentially, once the user is created with a UUID, there's no > way to map them to a new LDAP user, so I have no way to make Nextcloud > respect the new accounts, even if they have the same DN, without there > being a uuid field on the LDAP records. > > If might be able to open a PR for this. > > — > Reply to this email directly, view it on GitHub > <https://github.com/nitnelave/lldap/issues/293>, or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAGCPWNZU4VITCEAT6FC3HLV3JUUHANCNFSM57ZZOUDA> > . > You are receiving this because you are subscribed to this thread.Message > ID: ***@***.***> >
Author
Owner

@zicklag commented on GitHub (Aug 27, 2022):

Not for user modification though.

👍


OK, if I can't get around the need then I'll look into that. I might be able to get around for now and not need it, but we'll see.

Thanks.

<!-- gh-comment-id:1229278653 --> @zicklag commented on GitHub (Aug 27, 2022): > Not for user modification though. :+1: ---- OK, if I can't get around the need then I'll look into that. I might be able to get around for now and not need it, but we'll see. Thanks.
Author
Owner

@styt commented on GitHub (Oct 10, 2022):

Would you be open to exposing the uuid field for users and groups in the LDAP API?

I'm having an issue migrating my nextcloud instance to lldap because nextcloud uses the uuid field in order to map users to their Nextcloud equivalents. Essentially, once the user is created with a UUID, there's no way to map them to a new LDAP user, so I have no way to make Nextcloud respect the new accounts, even if they have the same DN, without there being a uuid field on the LDAP records.

If might be able to open a PR for this, but that's only if I don't find a work-around, because I'm quite busy, unfortunately.

Big thanks for LLDAP! ❤️

Hi,

Did you solve this? I am unable to map my LLDAP users to my existing Nextcloud users. I changed expert settings in Nextcloud to use UID but still get unique users so I guess I need to be able to map UUID for Nextcloud to see users as the same in LLDAP.

Thx
Stefan

<!-- gh-comment-id:1272870138 --> @styt commented on GitHub (Oct 10, 2022): > Would you be open to exposing the `uuid` field for users and groups in the LDAP API? > > I'm having an issue migrating my nextcloud instance to lldap because nextcloud uses the `uuid` field in order to map users to their Nextcloud equivalents. Essentially, once the user is created with a UUID, there's no way to map them to a new LDAP user, so I have no way to make Nextcloud respect the new accounts, even if they have the same DN, without there being a uuid field on the LDAP records. > > If might be able to open a PR for this, but that's only if I don't find a work-around, because I'm quite busy, unfortunately. > > Big thanks for LLDAP! ❤️ Hi, Did you solve this? I am unable to map my LLDAP users to my existing Nextcloud users. I changed expert settings in Nextcloud to use UID but still get unique users so I guess I need to be able to map UUID for Nextcloud to see users as the same in LLDAP. Thx Stefan
Author
Owner

@martadinata666 commented on GitHub (Oct 10, 2022):

I migrated with existing user to ldap, after setup a LDAP, dont forget override uuid with uid at expert tab, you need to drop the user except admin. And login using LDAP UID, the existing file with same UID will mapped directly.
The guide im using https://help.nextcloud.com/t/migration-to-ldap-keeping-users-and-data/13205

<!-- gh-comment-id:1272896298 --> @martadinata666 commented on GitHub (Oct 10, 2022): I migrated with existing user to ldap, after setup a LDAP, `dont forget override uuid with uid at expert tab`, you need to drop the user except admin. And login using LDAP UID, the existing file with same UID will mapped directly. The guide im using https://help.nextcloud.com/t/migration-to-ldap-keeping-users-and-data/13205
Author
Owner

@zicklag commented on GitHub (Oct 10, 2022):

I ended up not using it with Nextcloud for now, so no, I didn't get it working.

I tried overriding the UUID's in the LLDAP database using a SQL client, but I can't remember why I still couldn't get Nextcloud to connect after that.

<!-- gh-comment-id:1273315296 --> @zicklag commented on GitHub (Oct 10, 2022): I ended up not using it with Nextcloud for now, so no, I didn't get it working. I tried overriding the UUID's in the LLDAP database using a SQL client, but I can't remember why I still couldn't get Nextcloud to connect after that.
Author
Owner

@styt commented on GitHub (Oct 12, 2022):

Thanks for the comments so far. So far I have not been able to "sync" existing Nextcloud user with lldap user despite the same uid. I end up with a second account with a random number in the end.

<!-- gh-comment-id:1275656525 --> @styt commented on GitHub (Oct 12, 2022): Thanks for the comments so far. So far I have not been able to "sync" existing Nextcloud user with lldap user despite the same uid. I end up with a second account with a random number in the end.
Author
Owner

@zicklag commented on GitHub (Oct 12, 2022):

Yeah, I think that's what I ended up with. You have to make sure that the uuid field is the same, for Nextcloud to think that it's the same user.

Now I remember what issue I had. While I can use a SQL explorer to set the UUID field of the users in the LLDAP Sqlite database to be what they were in Nextcloud, LLDAP doesn't return that UUID in the LDAP query responses, so Nextcloud can't see it.

So we need LLDAP to return the uuid that it has in the database, to the LDAP queries that Nextcloud makes.

<!-- gh-comment-id:1276305673 --> @zicklag commented on GitHub (Oct 12, 2022): Yeah, I think that's what I ended up with. You have to make sure that the `uuid` field is the same, for Nextcloud to think that it's the same user. Now I remember what issue I had. While I can use a SQL explorer to set the UUID field of the users in the LLDAP Sqlite database to be what they were in Nextcloud, LLDAP doesn't _return_ that UUID in the LDAP query responses, so Nextcloud can't see it. So we need LLDAP to return the `uuid` that it has in the database, to the LDAP queries that Nextcloud makes.
Author
Owner

@nitnelave commented on GitHub (Oct 12, 2022):

Oh, I think I know the problem here: entryUUID is not part of the default list of attributes returned for a user. Maybe that's what's missing?

<!-- gh-comment-id:1276317920 --> @nitnelave commented on GitHub (Oct 12, 2022): Oh, I think I know the problem here: `entryUUID` is not part of the default list of attributes returned for a user. Maybe that's what's missing?
Author
Owner

@zicklag commented on GitHub (Oct 12, 2022):

Yes! I think Nextcloud might use a uuid attribute by default, or it's auto-detected, I can't remember, but you can probably tell it to use the entryUUID field either way.

<!-- gh-comment-id:1276325550 --> @zicklag commented on GitHub (Oct 12, 2022): Yes! I think Nextcloud might use a `uuid` attribute by default, or it's auto-detected, I can't remember, but you can probably tell it to use the `entryUUID` field either way.
Author
Owner

@styt commented on GitHub (Oct 12, 2022):

Hi, now I am thinking we are getting close on the issue....I have seen some threads about uuid being exposed but not fully aware of how far that has come, what we can expose so far? Can we currently modify uuid (to be the same as in Nextcloud) in lldap and have it to respond with it to Nextcloud as well? Thanks for your help here so far.

<!-- gh-comment-id:1276374914 --> @styt commented on GitHub (Oct 12, 2022): Hi, now I am thinking we are getting close on the issue....I have seen some threads about uuid being exposed but not fully aware of how far that has come, what we can expose so far? Can we currently modify uuid (to be the same as in Nextcloud) in lldap and have it to respond with it to Nextcloud as well? Thanks for your help here so far.
Author
Owner

@nitnelave commented on GitHub (Oct 12, 2022):

LLDAP will return the UUID if it's requested in the request. By default the response contains all the fields, but for LLDAP there's a bug and the UUID is not in "all the fields", which is I think the issue here.

To modify the UUID, you can do it directly in SQL with an sqlite3 client, there's currently no support in LLDAP. I'm open to PRs that will allow you to specify the UUID when creating a new user (but not modifying UUID of existing users).

<!-- gh-comment-id:1276394072 --> @nitnelave commented on GitHub (Oct 12, 2022): LLDAP will return the UUID if it's requested in the request. By default the response contains all the fields, but for LLDAP there's a bug and the UUID is not in "all the fields", which is I think the issue here. To modify the UUID, you can do it directly in SQL with an sqlite3 client, there's currently no support in LLDAP. I'm open to PRs that will allow you to specify the UUID when creating a new user (but not modifying UUID of existing users).
Author
Owner

@nitnelave commented on GitHub (Oct 12, 2022):

Alright, as soon as the image builds (in a couple of minutes) you can try with the latest LLDAP, that should give you the entryUUID in the response.

<!-- gh-comment-id:1276453319 --> @nitnelave commented on GitHub (Oct 12, 2022): Alright, as soon as the image builds (in a couple of minutes) you can try with the latest LLDAP, that should give you the entryUUID in the response.
Author
Owner

@styt commented on GitHub (Oct 15, 2022):

Hi,

I just want to say thank you and how amazing it is with how interactive this project is. I will try this over the weekend, I just need to read up a bit on editing the database directly.

I will let you know how it goes.

Thx
Stefan

<!-- gh-comment-id:1279749847 --> @styt commented on GitHub (Oct 15, 2022): Hi, I just want to say thank you and how amazing it is with how interactive this project is. I will try this over the weekend, I just need to read up a bit on editing the database directly. I will let you know how it goes. Thx Stefan
Author
Owner

@zicklag commented on GitHub (Oct 15, 2022):

I was able to use DBeaver to update the database, if you want to try that.

<!-- gh-comment-id:1279750186 --> @zicklag commented on GitHub (Oct 15, 2022): I was able to use [DBeaver](https://github.com/dbeaver/dbeaver) to update the database, if you want to try that.
Author
Owner

@styt commented on GitHub (Oct 28, 2022):

I was able to use DBeaver to update the database, if you want to try that.

Hi,

Do You remember how You did run this? I have two problems, I want to update an uid to lowercase, e.g. "Adam" to "adam" but also delete a bunch of garbage users (and all references) after playing around with LDAP configuration too much such as "adam_1234", "adam_5678" etc. etc. Would be grateful for any real examples of code as I am not succeeding with what I am trying to achieve unfortunately. Thx

<!-- gh-comment-id:1295240996 --> @styt commented on GitHub (Oct 28, 2022): > I was able to use [DBeaver](https://github.com/dbeaver/dbeaver) to update the database, if you want to try that. Hi, Do You remember how You did run this? I have two problems, I want to update an uid to lowercase, e.g. "Adam" to "adam" but also delete a bunch of garbage users (and all references) after playing around with LDAP configuration too much such as "adam_1234", "adam_5678" etc. etc. Would be grateful for any real examples of code as I am not succeeding with what I am trying to achieve unfortunately. Thx
Author
Owner

@nitnelave commented on GitHub (Oct 28, 2022):

Maybe relevant: UID in LLDAP are always lowercase. And if you delete a user (either from the web UI or directly in the users table in the DB), all references will be deleted.

<!-- gh-comment-id:1295247871 --> @nitnelave commented on GitHub (Oct 28, 2022): Maybe relevant: UID in LLDAP are always lowercase. And if you delete a user (either from the web UI or directly in the `users` table in the DB), all references will be deleted.
Author
Owner

@zicklag commented on GitHub (Oct 28, 2022):

On my Linux laptop I just downloaded the app, unzipped it and started it from the commandline, but they have installers for Mac and Windows here, too.

After starting I created a new database connection, selected Sqlite and the path to my database, and then I was able to browse the tables in the UI and manually edit rows and columns.

I'm not well versed in SQL, so I don't know about how to update all the records in an automated fashion, if you have tons of rows to modify.

<!-- gh-comment-id:1295250393 --> @zicklag commented on GitHub (Oct 28, 2022): On my Linux laptop I just downloaded the app, unzipped it and started it from the commandline, but they have installers for Mac and Windows [here](https://github.com/dbeaver/dbeaver/releases/tag/22.2.3), too. After starting I created a new database connection, selected Sqlite and the path to my database, and then I was able to browse the tables in the UI and manually edit rows and columns. I'm not well versed in SQL, so I don't know about how to update all the records in an automated fashion, if you have tons of rows to modify.
Author
Owner

@styt commented on GitHub (Oct 28, 2022):

Thank You both for the quick reply.

I am not that savvy in SQL either and it seems I have a bit of scripting to do in the NC database. I need to clean up a lot of obsolete users as I mentioned after my try-outs with lldap but also to rename uid with capital first letter in NC to align with all lowercase in lldap.
Seems a bit cumbersome to make sure the edits are across all tables. But no star in SQL....

<!-- gh-comment-id:1295504348 --> @styt commented on GitHub (Oct 28, 2022): Thank You both for the quick reply. I am not that savvy in SQL either and it seems I have a bit of scripting to do in the NC database. I need to clean up a lot of obsolete users as I mentioned after my try-outs with lldap but also to rename uid with capital first letter in NC to align with all lowercase in lldap. Seems a bit cumbersome to make sure the edits are across all tables. But no star in SQL....
Author
Owner

@eapetitfils commented on GitHub (Nov 1, 2022):

Hi,

My comment is not fully relevant to the initial topic but I just did a migration from openldap to lldap and updated nextcloud to work with the new accounts. The main reason I wanted to bring it up here is that I did not need to update the uuid in the end.

What I did is update the LDAP settings in nextcloud to connect to LLDAP (where I had created the new accounts). However, nextcloud is using the DN to uniquely identify the users and my openldap was using a DN in the form uid=daniel,ou=users,dc=example,dc=com while LLDAP has uid=daniel,ou=people,dc=example,dc=com. Because of this, logging in would create a new user account.

In order to fix this, I updated the table oc_ldap_user_mapping in the database using HeidiSQL (dbeaver or any other that suits you works as well). I updated the ldap_dn fields accordingly, changing "users" to "people". However, you also need to change the field ldap_dn_hash as this is actually what Nextcloud uses. This column is, at the time of writing this comment, computed by simply doing a sha256 of the ldap_dn field, with values in lower case. I did not update the directory_uuid and so far everything seems to wor. Actually, the values there seem different from even my openldap uuids.

Edit:

You might still need to correct the uuid if nextcloud is configured to use to as a default name for the directory. This is I believe the default behaviour of nextcloud. I did not have this problem as I had setup nextcloud to use the uid (aka the username) so the different uuid was not an issue.

<!-- gh-comment-id:1298585043 --> @eapetitfils commented on GitHub (Nov 1, 2022): Hi, My comment is not fully relevant to the initial topic but I just did a migration from openldap to lldap and updated nextcloud to work with the new accounts. The main reason I wanted to bring it up here is that I did not need to update the `uuid` in the end. What I did is update the LDAP settings in nextcloud to connect to LLDAP (where I had created the new accounts). However, nextcloud is using the DN to uniquely identify the users and my openldap was using a DN in the form `uid=daniel,ou=users,dc=example,dc=com` while LLDAP has `uid=daniel,ou=people,dc=example,dc=com`. Because of this, logging in would create a new user account. In order to fix this, I updated the table `oc_ldap_user_mapping` in the database using HeidiSQL (dbeaver or any other that suits you works as well). I updated the `ldap_dn` fields accordingly, changing "users" to "people". However, you also need to change the field `ldap_dn_hash` as this is actually what Nextcloud uses. This column is, at the time of writing this comment, computed by simply doing a sha256 of the `ldap_dn` field, with values in lower case. I did not update the `directory_uuid` and so far everything seems to wor. Actually, the values there seem different from even my openldap uuids. Edit: You might still need to correct the uuid if nextcloud is configured to use to as a default name for the directory. This is I believe the default behaviour of nextcloud. I did not have this problem as I had setup nextcloud to use the uid (aka the username) so the different uuid was not an issue.
Author
Owner

@styt commented on GitHub (Nov 2, 2022):

Thanks @eapetitfils . Still very valid information for people migrating and using Nextcloud.
I have been able to purge my bunch of obsolete account created during my attempts to map account with lldap and NC.
Last thing I have is to rename uid in NC with capital letter to all lowercase but have not dared to pull the trigger yet. There were so many references to the uid in different columns in different tables. Last piece I hope to map NC users to LLDAP user.

<!-- gh-comment-id:1300460073 --> @styt commented on GitHub (Nov 2, 2022): Thanks @eapetitfils . Still very valid information for people migrating and using Nextcloud. I have been able to purge my bunch of obsolete account created during my attempts to map account with lldap and NC. Last thing I have is to rename uid in NC with capital letter to all lowercase but have not dared to pull the trigger yet. There were so many references to the uid in different columns in different tables. Last piece I hope to map NC users to LLDAP user.
Author
Owner

@nitnelave commented on GitHub (Sep 12, 2023):

If there's nothing else to add here, I'm closing this issue.

<!-- gh-comment-id:1715813110 --> @nitnelave commented on GitHub (Sep 12, 2023): If there's nothing else to add here, I'm closing this issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/lldap-lldap#111
No description provided.