diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 6f98129fbd950..c8882f7b00854 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -513,6 +513,9 @@ public function editUser(string $userId, string $key, string $value): DataRespon break; case 'password': try { + if (!$targetUser->canChangePassword()) { + throw new OCSException('Setting the password is not supported by the users backend', 103); + } $targetUser->setPassword($value); } catch (HintException $e) { // password policy error throw new OCSException($e->getMessage(), 103); diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 0d6d811acbc54..7b235a1d5abee 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -1270,6 +1270,10 @@ public function testEditUserRegularUserSelfEditChangePassword() { ->method('get') ->with('UserToEdit') ->will($this->returnValue($targetUser)); + $targetUser + ->expects($this->once()) + ->method('canChangePassword') + ->will($this->returnValue(true)); $targetUser ->expects($this->once()) ->method('setPassword')