|
2 | 2 | title: Http server returned Forbidden exception |
3 | 3 | description: Provides a solution to an error that occurs when you select the Test & Enable Mailbox button on a mailbox record in Dynamics 365. |
4 | 4 | ms.reviewer: |
5 | | -ms.topic: troubleshooting |
6 | | -ms.date: 11/19/2024 |
| 5 | +ms.date: 12/30/2024 |
7 | 6 | ms.custom: sap:Email and Exchange Synchronization |
8 | 7 | --- |
9 | | -# "Http server returned Forbidden exception" error appears in Microsoft Dynamics 365 mailbox |
| 8 | +# "Http server returned Forbidden exception" error when testing a Dynamics 365 mailbox |
10 | 9 |
|
11 | | -This article provides a solution to an error that occurs when you select the **Test & Enable Mailbox** button on a mailbox record in Dynamics 365. |
| 10 | +This article provides a solution to an error that occurs when you select the **Test & Enable Mailbox** button on a mailbox record in Microsoft Dynamics 365. |
12 | 11 |
|
13 | 12 | _Applies to:_ Microsoft Dynamics 365 |
14 | 13 | _Original KB number:_ 4483440 |
15 | 14 |
|
16 | 15 | ## Symptoms |
17 | 16 |
|
18 | | -When you select the **Test & Enable Mailbox** button on a mailbox record in Dynamics 365, the test results section shows Failure and the following alert is logged: |
| 17 | +When you select the **Test & Enable Mailbox** button on a mailbox record in Dynamics 365, the test results section shows **Failure** and the following alert is logged: |
19 | 18 |
|
20 | | -> "The email message "Your mailbox is now connected to Dynamics 365" cannot be sent because an error occurred while establishing a secure connection to the email server. Mailbox [Mailbox Name] didn't synchronize. The owner of the email server profile Microsoft Exchange Online has been notified. |
21 | | -Email Server Error Code: Http server returned Forbidden exception." |
| 19 | +> The email message "Your mailbox is now connected to Dynamics 365" cannot be sent because an error occurred while establishing a secure connection to the email server. Mailbox [Mailbox Name] didn't synchronize. The owner of the email server profile Microsoft Exchange Online has been notified. |
| 20 | +> **Email Server Error Code**: Http server returned Forbidden exception. |
22 | 21 |
|
23 | | -If you select **Details**, the following other details are shown: |
| 22 | +If you select **Details**, the following details are shown: |
24 | 23 |
|
25 | | -> "Error : System.Net.WebException: The request failed with HTTP status 403: Forbidden. |
26 | | - at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) |
27 | | - at System.Web.Services.Protocols.SoapHttpClientProtocol.EndInvoke(IAsyncResult asyncResult) |
28 | | - at Microsoft.Crm.Asynchronous.EmailConnector.ExchangeServiceBinding.EndCreateItem(IAsyncResult asyncResult) |
29 | | - at Microsoft.Crm.Asynchronous.EmailConnector.ExchangeOutgoingEmailProvider.EndCreateItem()" |
| 24 | +> Error : System.Net.WebException: The request failed with HTTP status 403: Forbidden. |
| 25 | +> at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) |
| 26 | +> at System.Web.Services.Protocols.SoapHttpClientProtocol.EndInvoke(IAsyncResult asyncResult) |
| 27 | +> at Microsoft.Crm.Asynchronous.EmailConnector.ExchangeServiceBinding.EndCreateItem(IAsyncResult asyncResult) |
| 28 | +> at Microsoft.Crm.Asynchronous.EmailConnector.ExchangeOutgoingEmailProvider.EndCreateItem() |
30 | 29 |
|
31 | 30 | ## Cause |
32 | 31 |
|
33 | | -Dynamics 365 communicates with Microsoft Exchange using Exchange Web Services (EWS) requests. If EWS is disabled, this error will occur. The following contents are some potential ways that EWS may be disabled or restricted in Exchange: |
| 32 | +Dynamics 365 communicates with Microsoft Exchange using Exchange Web Services (EWS) requests. If EWS is disabled, this error occurs. Here are some potential ways that EWS might be disabled or restricted in Exchange: |
34 | 33 |
|
35 | | -1. EWS is disabled for the mailbox |
36 | | -2. EWS is disabled for the entire organization |
37 | | -3. The `EwsApplicationAccessPolicy` is set to **EnforceAllowList** and `the EwsAllowList` doesn't allow access from Dynamics 365 (CRM). |
38 | | -4. The `EwsApplicationAccessPolicy` is set to **EnforceBlockList** and `the EwsBlockList` includes Dynamics 365 (CRM). |
| 34 | +1. EWS is disabled for the mailbox. |
| 35 | +2. EWS is disabled for the entire organization. |
| 36 | +3. The `EwsApplicationAccessPolicy` is set to **EnforceAllowList** and the `EwsAllowList` doesn't allow access from Dynamics 365. |
| 37 | +4. The `EwsApplicationAccessPolicy` is set to **EnforceBlockList** and the `EwsBlockList` includes Dynamics 365. |
39 | 38 |
|
40 | 39 | ## Resolution |
41 | 40 |
|
42 | | -**If the issue only occurs for some mailboxes, check if EWS is disabled for the mailbox:** |
| 41 | +### Check if EWS is disabled for the mailbox if the issue only occurs for some mailboxes |
43 | 42 |
|
44 | | -1. First check to see if EWS has been disabled for the mailbox. Use the following PowerShell command: |
| 43 | +1. First, check if EWS is disabled for a specific mailbox using this PowerShell command: |
45 | 44 |
|
46 | 45 | ```powershell |
47 | 46 | Get-CASMailbox <mailbox-alias> | ft EwsEnabled |
48 | 47 | ``` |
49 | 48 |
|
50 | | -2. If **EwsEnabled** is set to **False**, use the following PowerShell command to enable Exchange Web Services (EWS) for the mailbox: |
| 49 | +2. If **EwsEnabled** is set to **False**, enable it using this command: |
51 | 50 |
|
52 | 51 | ```powershell |
53 | 52 | Set-CASMailbox <mailbox-alias> -EwsEnabled $True |
54 | 53 | ``` |
55 | 54 |
|
56 | 55 | > [!IMPORTANT] |
57 | | - > After running this command, it may take up to 120 minutes before the setting change takes effect. |
| 56 | + > After running this command, it might take up to 120 minutes before the setting change takes effect. |
58 | 57 |
|
59 | | - **If the issue occurs for all mailboxes, check if EWS is disabled at the organization level, or if the EwsAllowList is being used to limit what EWS traffic is allowed.** |
| 58 | +## Check if EWS is disabled at the organization level or if the EwsAllowList limits the EWS traffic |
60 | 59 |
|
61 | | -1. Use the following PowerShell command to see if any of the EWS settings are configured: |
| 60 | +1. Use this PowerShell command to check organization-level settings: |
62 | 61 |
|
63 | 62 | ```powershell |
64 | 63 | Get-OrganizationConfig |ft Name, EwsEnabled,EwsApplicationAccessPolicy,EwsBlockList,EwsAllowList |
65 | 64 | ``` |
66 | 65 |
|
67 | | -2. Verify that **EwsEnabled** isn't set to **False**. The following command can be used to set **EwsEnabled** to **True** if it's currently set to **False**: |
| 66 | +2. Ensure that `EwsEnabled` isn't set to **False**. If it is, enable it using: |
68 | 67 |
|
69 | 68 | ```powershell |
70 | 69 | Set-OrganizationConfig -EwsEnabled $True |
71 | 70 | ``` |
72 | 71 |
|
73 | 72 | > [!IMPORTANT] |
74 | | - > After running this command, it may take up to 120 minutes before the setting change takes effect. |
| 73 | + > After running this command, it might take up to 120 minutes before the setting change takes effect. |
75 | 74 |
|
76 | | -3. If `EwsApplicationAccessPolicy` is set to **EnforceAllowList** and the `EwsAllowList` doesn't contain a value for CRM (Example: CRM/\*), which would prevent Dynamics 365 (CRM) from being able to communicate with Exchange. Use the following command to update the list to include CRM/* and whatever other applications you want to allow (\<PreviousAllowList> in the following example): |
| 75 | +3. If `EwsApplicationAccessPolicy` is set to **EnforceAllowList**, check if the `EwsAllowList` contains a value for CRM (for example, CRM/\*) to allow Dynamics 365 (CRM) to communicate with Exchange. If it does not, use the following command to update the list to include CRM/* and any other applications you want to allow. In this example \<PreviousAllowedList> is the list of applications that were previously in the allowlist: |
77 | 76 |
|
78 | 77 | ```powershell |
79 | 78 | Set-OrganizationConfig -EwsApplicationAccessPolicy:EnforceAllowList -EwsAllowList:CRM/*,<PreviousAllowedList> |
80 | 79 | ``` |
81 | 80 |
|
82 | 81 | > [!IMPORTANT] |
83 | | - > After running this command, it may take up to 120 minutes before the setting change takes effect. |
| 82 | + > After running this command, it might take up to 120 minutes before the setting change takes effect. |
84 | 83 |
|
85 | | -4. If `EwsApplicationAccessPolicy` is set to **EnforceBlockList** and the **EwsAllowList** contains a value for CRM (Example: CRM/*), which would prevent Dynamics 365 (CRM) from being able to communicate with Exchange. Use the following command to update the list to no longer include CRM: |
| 84 | +4. If `EwsApplicationAccessPolicy` is set to **EnforceBlockList**, check if the `EwsBlockList` contains a value for CRM (for example, CRM/*), which prevents Dynamics 365 (CRM) from communicating with Exchange. If it does, use the following command to update the list to no longer include CRM. In this example \<PreviousBlockList WITH CRM REMOVED> is the list of applications that were previously in the blocklist except for CRM: |
86 | 85 |
|
87 | 86 | ```powershell |
88 | 87 | Set-OrganizationConfig -EwsApplicationAccessPolicy:EnforceBlockList -EwsBlockList:<PreviousBlockList WITH CRM REMOVED> |
89 | 88 | ``` |
90 | 89 |
|
91 | 90 | > [!IMPORTANT] |
92 | | - > After running this command, it may take up to 120 minutes before the setting change takes effect. |
| 91 | + > After running this command, it might take up to 120 minutes before the setting change takes effect. |
93 | 92 |
|
94 | 93 | ## More information |
95 | 94 |
|
|
0 commit comments