diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index edb42efa2ce15..d38b100391e26 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 adbdb9d8685e3..5528a79f3ed53 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -1231,6 +1231,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')