How to Configure Conditional Access for SharePoint Geofencing and MFA
Question details
The administrator needs to restrict SharePoint and OneDrive access using location-based conditions, allowing passwordless access inside the office while requiring Multi-Factor Authentication (MFA) for external access.

- Product
- Microsoft 365
- Device & OS
- not provided
- Scenario
- Implementing location-based access controls to protect corporate data by requiring MFA only when users attempt to access resources from outside the trusted corporate network.
- Observed behavior
- Users currently experience either uniform MFA prompts or a lack of enforcement; the goal is to trigger MFA conditionally based on whether the user's IP address matches a trusted office location.
Ensure you have Global Administrator, Conditional Access Administrator, or Security Administrator privileges in your Microsoft Entra ID (formerly Azure AD) tenant, and an active Microsoft Entra ID P1 or P2 license.
Create a Location-Based Conditional Access Policy in Microsoft Entra ID
Use Microsoft Entra ID to define trusted corporate IP ranges and enforce a Conditional Access policy that requires MFA only when SharePoint or OneDrive are accessed from non-trusted locations.
Conditional Access policies evaluate identity signals (like IP address and location) to determine whether a user should be granted access, required to provide additional verification (MFA), or blocked entirely.
By defining your office network as a 'named location' and excluding it from the MFA requirement, you create a seamless login experience for internal employees while protecting data from external threats.
Sign in to the Microsoft Entra admin center. Navigate to Protection > Conditional Access > Named locations. Click 'IP ranges location', enter your office public IP addresses, check the 'Mark as trusted location' box, and save.
Go to Protection > Conditional Access > Policies and select 'New policy'. Give the policy a descriptive name, such as 'SharePoint Geofencing and MFA'.
Under 'Users', select the specific groups or users this policy should apply to. Under 'Target resources' (or Cloud apps), choose 'Select apps' and search for 'Office 365 SharePoint Online'. This automatically encompasses OneDrive as well.
Under 'Conditions', click 'Locations'. Turn the configuration 'On'. Under the 'Include' tab, select 'Any location'. Under the 'Exclude' tab, select 'Selected locations' and choose the trusted IP range you created in the first step.
Under 'Access controls' > 'Grant', select 'Grant access' and check the 'Require multifactor authentication' box. Click 'Select' to apply.
Set the policy state to 'Report-only' initially to verify its impact via sign-in logs without disrupting users. Once you confirm it works as intended, change the state to 'On' and click 'Save'.

A Powerful and Free Microsoft Office Alternative
While managing enterprise access controls via Microsoft Entra is essential for securing SharePoint, your users also need a fast, reliable, and highly compatible office suite for daily document creation. WPS Office provides a seamless, cost-effective alternative to Microsoft Office desktop applications.

Frequently Asked Questions
Do I need a specific license to use Conditional Access policies?
Yes, creating and enforcing Conditional Access policies requires your tenant to have Microsoft Entra ID P1 or P2 licenses (formerly known as Azure AD Premium P1/P2).
Does targeting SharePoint in the policy automatically cover OneDrive?
Yes. In Microsoft Entra Conditional Access, selecting 'Office 365 SharePoint Online' as the target cloud application applies the same security controls to both SharePoint and OneDrive for Business.
Why are my users still being prompted for MFA when inside the office network?
This usually happens if the public IP address the users are presenting to Microsoft 365 does not exactly match the IP ranges defined in your trusted 'Named locations'. Additionally, ensure there isn't another conflicting Conditional Access policy enforcing MFA globally.
How can I safely test this policy without locking out executives?
You should use the 'Report-only' mode when initially saving the policy. This logs the results of the policy evaluation during user sign-ins without actually enforcing the MFA prompt. You can review the Microsoft Entra sign-in logs to verify the results before switching the policy to 'On'.




