From 18d76f987c59898148877a0da8f15032227b1d9e Mon Sep 17 00:00:00 2001 From: James McQuillan Date: Mon, 1 Feb 2016 21:51:42 -0500 Subject: [PATCH] MSFTMPP-339: Fix errors in cron assigning users to application --- classes/rest/azuread.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/classes/rest/azuread.php b/classes/rest/azuread.php index 02a8e01b1..44bfd24ed 100644 --- a/classes/rest/azuread.php +++ b/classes/rest/azuread.php @@ -308,7 +308,19 @@ public function assign_user($muserid, $userid, $appobjectid) { 'odata.type' => 'Microsoft.DirectoryServices.AppRoleAssignment', 'objectType' => 'AppRoleAssignment', ); - $response = $this->process_apicall_response($response, $expectedparams); + + try { + $response = $this->process_apicall_response($response, $expectedparams); + } catch (\Exception $e) { + // This error here probably means the user is already assigned, so we can continue. process_apicall_response + // will log any real errors anyway. + $msg = 'One or more properties are invalid.'; + $string = get_string('erroro365apibadcall_message', 'local_o365', htmlentities($msg)); + if ($e->getMessage() !== $string) { + throw $e; + } + } + if (empty($record)) { $record = new \stdClass; $record->muserid = $muserid;