Change display name break group associations

First changing the display name only works on UI not with api
testcase:
MYURL=“https://${PoNCoadmin}:${PoNCoADMINoPASSWORD}@${PoDOMAIN}/nextcloud/ocs/v1.php/cloud/users”
MYUSER=Mitarbeiter1.Buchhaltung
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname="${MYUSER}"

curl -X PUT -H “OCS-APIRequest:true” -X GET ${MYURL}/${MYUSER}

Second, if I change the displayname via user interface, all existing group associations will break.

It’s about nextcloud 18.0.1

Hi kiz,

To me it looks like you have a little error in your syntax. This might be the problem, why you can’t change the displayname via API.

Yours:

MYURL=“https://${PoNCoadmin}:${PoNCoADMINoPASSWORD}@${PoDOMAIN}/nextcloud/ocs/v1.php/cloud/users”
MYUSER=Mitarbeiter1.Buchhaltung

curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname="${MYUSER}"

curl -X PUT -H “OCS-APIRequest:true” -X GET ${MYURL}/${MYUSER}

Try this instead:

MYURL=https://${PoNCoadmin}:${PoNCoADMINoPASSWORD}@${PoDOMAIN}/nextcloud/ocs/v1.php/cloud/users
MYUSER=Mitarbeiter1.Buchhaltung

curl -X PUT ${MYURL}/${MYUSER} -d key="displayname" -d value="NEW_DISPLAYNAME" --header "OCS-APIRequest: true"

Regarding changing the display name in the UI linked to group associations breaking, I tried this on my NC playground version 17.0.3 but could not reproduce it. If you do so, please could you provide some log entries from that specific time?

I validate your suggestion:

Blockquote
developer@localhost:~$ curl -X PUT -H “OCS-APIRequest:true” -X GET ${MYURL}/${MYUSER}

<?xml version="1.0"?> ok 100 OK 1 /nextcloud-data/Mitarbeiter1.Buchhaltung Mitarbeiter1.Buchhaltung 1582550385000 Database 1056827993 16913831 1073741824 1.58 1073741824 info@kommunikation-im-zentrum.de Mitarbeiter1.Buchhaltung Musterfirma.Buchhaltung Musterfirma.BuM de 1 1

Blockquote
developer@localhost:~$ curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d key=“displayname” -d value=“abc”

but no change in displayname

Blockquote
developer@localhost:~$ curl -X PUT -H “OCS-APIRequest:true” -X GET ${MYURL}/${MYUSER}

<?xml version="1.0"?> ok 100 OK 1 /nextcloud-data/Mitarbeiter1.Buchhaltung Mitarbeiter1.Buchhaltung 1582550385000 Database 1056827993 16913831 1073741824 1.58 1073741824 info@kommunikation-im-zentrum.de Mitarbeiter1.Buchhaltung Musterfirma.Buchhaltung Musterfirma.BuM de 1 1

testcase

MYURL=“https://${PoNCoadmin}:${PoNCoADMINoPASSWORD}@${PoDOMAIN}/nextcloud/ocs/v1.php/cloud/users”
MYGROUP1=MusterFirma
MYGROUP2=Musterfirma.Buchhaltung
MYGROUP3=Musterfirma.Marketing
MYGROUP4=Musterfirma.Logistik
MYGROUP5=Musterfirma.BuM
MYGROUP6=Musterfirma.MuL

MYUSER=Mitarbeiter1.Buchhaltung
curl -X PUT -H “OCS-APIRequest:true” -X GET ${MYURL}/${MYUSER}
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d key=“displayname” -d value=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X GET ${MYURL}/${MYUSER}/groups
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP2}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP5}”
curl -X PUT -H “OCS-APIRequest:true” -X GET ${MYURL}/${MYUSER}/groups
MYUSER=Mitarbeiter2.Buchhaltung
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP2}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP5}”
MYUSER=Mitarbeiter3.Buchhaltung
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP2}”

MYUSER=Mitarbeiter1.Marketing
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP1}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP3}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP5}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP6}”
MYUSER=Mitarbeiter2.Marketing
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP1}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP3}”
MYUSER=Mitarbeiter3.Marketing
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP1}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP3}”

MYUSER=Mitarbeiter1.Logistik
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP1}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP4}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP6}”
MYUSER=Mitarbeiter2.Logistik
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP1}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP4}”
MYUSER=Mitarbeiter3.Logistik
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER} -d displayname=“${MYUSER}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP1}”
curl -X PUT -H “OCS-APIRequest:true” -X POST ${MYURL}/${MYUSER}/groups -d groupid=“${MYGROUP4}”

I’m not sure why you use the -X flag twice?

Just execute the command:

curl -X PUT ${MYURL}/${MYUSER} -d key="displayname" -d value="NEW_DISPLAYNAME" --header "OCS-APIRequest: true"

This would change the display name to NEW_DISPLAYNAME

after I change displayname of Mitarbeiter1.Buchhaltung and Mitarbeiter2.Buchhaltung I do not see them in my contact list anymore.

thank you - works

You can shorten the --header “OCS-APIRequest: true” as well by just using -H “OCS-APIRequest: true”, which you were using before.

Looking at your cURL stuff from above, I would suggest revising all of them by removing the second -X flag. This is probably causing the issues you’re having.

did not get it

Blockquote
works: curl -X PUT -H “OCS-APIRequest:true” -X GET ${MYURL}/${MYUSER}
do not work: curl -X PUT -H “OCS-APIRequest:true” GET ${MYURL}/${MYUSER}

You are doing the same thing again :wink:

The -X flag is a request flag for a method (GET, POST, PUT, etc.) - If you add two request method flags, the second one will overwrite the first one, which causes issues.

Your example from above should look like this:

curl -X GET ${MYURL}/${MYUSER} -H “OCS-APIRequest:true”

thank you got it

thank you regarding the first topic. => done.
regarding the second topic, I validate it again (with the fixed api script) and it worked. BUT doing the same (change displayname) with UI it breaks the group-associations.
any suggestions?

What version of Nextcloud are you using?

Also, if you change the display name in the web UI and it breaks the group association, please could you check your Nextcloud log to see if it shows anything user/group related at the time of the change?

It could be a unnoticed bug, that’s what we need to find out :slight_smile:

Nextcloud Version 18.0.1, no log entry

No log entries? In that case I pretty much think, that this is a bug.

Please could you report this at the Nextcloud GitHub page, so that the developers can have a look at this? Please could you also link the new issue on Github on here, so that other who may encounter this, will see it?

did it. https://github.com/nextcloud/server/issues/19627

1 Like