There are a number of ways to block undesirable connections from Exchange. Take a look at the parent article for other methods. Using this method, we can utilize a built-in feature of IIS 7 and above to prevent access from specific clients or client behavior.
Examples
Scenario 1 A VIP while traveling changed their password. Unfortunately an ActiveSync device left at home continues to synchronize and eventually causes the VIP's Active Directory (AD) account to get locked. The VIP needs to work while traveling but doesn't want to remote wipe the device. The key pieces that make this a good example for URL rewrite are, a unique DeviceID, and the need to block before authentication. The Allow Block Quarantine (ABQ) feature in Exchange 2010 or or configuring the allow list at the CASmailbox layer wouldn't work here since the authentication module is engaged before a deviceID can be blocked. Scenario 2 Certain behavior identified by a new version of a client causes performance issues with Exchange. For example, iOS 6.1 can cause high CPU and transaction log growth when very specific actions are taken. Although we know how to block all devices of a user agent, in this case we just want to prevent these devices from performing the action. The key pieces that make this a good example for URL rewrite are, a user agent, and a specific URL string that identifies the action.
Scenario 1 A VIP while traveling changed their password. Unfortunately an ActiveSync device left at home continues to synchronize and eventually causes the VIP's Active Directory (AD) account to get locked. The VIP needs to work while traveling but doesn't want to remote wipe the device. The key pieces that make this a good example for URL rewrite are, a unique DeviceID, and the need to block before authentication. The Allow Block Quarantine (ABQ) feature in Exchange 2010 or or configuring the allow list at the CASmailbox layer wouldn't work here since the authentication module is engaged before a deviceID can be blocked.
Scenario 2 Certain behavior identified by a new version of a client causes performance issues with Exchange. For example, iOS 6.1 can cause high CPU and transaction log growth when very specific actions are taken. Although we know how to block all devices of a user agent, in this case we just want to prevent these devices from performing the action. The key pieces that make this a good example for URL rewrite are, a user agent, and a specific URL string that identifies the action.
Whenever considering a URL rewrite solution, first verify with your perimeter solution. The most desirable solution implementation is at the perimeter, instead of each individual Client Access Server (CAS). Also, since many perimeter solutions are Application aware (layer 7 in the OSI model), a custom response from the URL rewrite may trigger an unexpected response from the perimeter solution. Here's a great example from the F5 community of an application aware perimeter solution that sparked the idea for the URL rewrite for the iOS 6.1 issue.
1. Download and Install URL Rewrite Module After downloading and installing URL Rewrite Module 2.0 from http://www.microsoft.com/en-us/download/details.aspx?id=7435 you'll see a new module available in IIS manager. 2. Decide what layer is most appropriate to configure the rule You can create a rule at the Web Site level, or the virtual directory level. In Scenario 1, we would want to place the rule at the Default Web Site level in order to act upon the request before the authentication module is reached. In Scenario 2, the best place to configure the rule is at the Microsoft-Server-Activesync virtual directory. You can verify the layer the rule is applied by viewing the input field showing "URL path after".
3. Create a rule For simple rules like the example in Scenario 1, choose the "Request Blocking rule" Here's the options to choose for a rule that blocks a specific Device ID. The Blank rule is better suited for more complex requirements like Scenario 2. Here's what the options should look like for blocking any request with the MeetingResponse command coming from an iOS 6.1 or iOS 6.1.1 device. Since iOS 6.1.2 appears to fix the issue and the user agent is 1002.146 or higher, we can't use the wildcard notation. Instead we can use Regular Expressions as detailed in the figure below. After hitting Apply, the rule takes effect immediately. 4. Copying the Rule. To replicate this rule to other Exchange CAS, you can use the URL Rewrite GUI again, or you can insert the appropriate configuration information directly into the web.config file for the level you created the rule for. Be sure to make a backup of the original web.config. In the example above, the Scenario 1 rule for the DeviceID would go in the <system.webServer> section of the web.config for the Default Web Site [by default located C:\inetpub\wwwroot]
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="DeviceID block" patternSyntax="Wildcard" stopProcessing="true"> <match url="*" /> <conditions> <add input="{QUERY_STRING}" pattern="*DeviceId=E3335CDF280E06835EE8529B688405DF*" /> </conditions> <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." /> </rule> </rules> </rewrite> </system.webServer> </configuration>
<rewrite> <rules> <rule name="iOS 6.1 to 6.1.1 block meeting response" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_USER_AGENT}" pattern="^Apple.*1002[.]14[12345]" /> <add input="{QUERY_STRING}" pattern=".*Cmd=MeetingResponse.*" /> </conditions> <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." /> </rule> </rules> </rewrite>
netsh http flush logbuffer dir C:\inetpub\logs\LogFiles\W3SVC1\u_exyymmdd.log | select-string "403 0 " | Select-Object -last 20 If you see results like this, then you will know the rule is working correctly. ... C:\inetpub\logs\LogFiles\W3SVC1\u_ex130215.log:2528:2013-02-15 20:59:51 192.168.1.50 POST /Microsoft-Server-ActiveSync/default.eas User=jane.doe@fabrikam.com&DeviceId=ApplALLURBASE&DeviceType=iPad&Cmd=MeetingResponse 443 - 172.16.1.110 Apple-iPad2C1/1002.141 403 0 0 93 ... C:\inetpub\logs\LogFiles\W3SVC1\u_ex130215.log:2889:2013-02-15 23:05:31 192.168.1.50 POST /Microsoft-Server-ActiveSync/default.eas User=john.doe&DeviceId=Appl8675309&DeviceType=iPhone&Cmd=MeetingResponse 443 - 172.16.1.104 Apple-iPhone3C1/1002.144 403 0 0 78 ...
netsh http flush logbuffer dir C:\inetpub\logs\LogFiles\W3SVC1\u_exyymmdd.log | select-string "403 0 " | Select-Object -last 20
If you see results like this, then you will know the rule is working correctly.
7. What is the end-user experience? After implementing the rule, iOS 6.1/6.1.x users will have a different experience when it comes to meetings.