Restrict Microsoft 365 Access by IP Address with AD FS Claim Rules
Question details
Restrict Microsoft 365 authentication to approved IP addresses, with an exception for members of a permitted Active Directory group.

- Product
- Active Directory Federation Services (AD FS) and Microsoft 365
- Device & OS
- not provided
- Scenario
- An administrator wants to configure IP-based access restrictions and a group exception in the Microsoft 365 relying-party trust.
- Observed behavior
- The desired configuration permits authentication from approved IP addresses or by members of the permitted group, and denies other requests.
Identify the Microsoft 365 relying-party trust, approved public IPv4 and IPv6 addresses, and the Active Directory group that will receive the exception. Check which client IP claim is available for each sign-in path, and test changes in a controlled environment with an emergency administrator access method.
Configure AD FS authorization rules for approved IPs and group members
Use the Microsoft 365 relying-party trust to deny requests that meet neither the approved-IP condition nor the group exception.
Use Microsoft’s AD FS claim-rule documentation to construct and validate the custom rules for your environment. IP claim availability and formatting can vary by protocol and proxy path; do not assume that every request contains a trustworthy end-user address.
Authorization rules must be able to evaluate the IP and group information available at the authorization stage. Do not rely on a claim produced only later by an issuance transform rule.
On an AD FS management server, open AD FS Management, select Relying Party Trusts, and locate the Microsoft 365 trust.
Open the trust’s claim rules or access control policy settings. Check the existing authorization rules before adding a custom rule; the available options depend on the AD FS version.
In the applicable authorization rule editor, use custom rules to evaluate the appropriate client IP claim and the permitted Active Directory group. Follow Microsoft’s claim-rule syntax for your IP claim’s actual format and for group membership checks.
Add an authorization rule that denies a request only when its IP is not approved and the user is not a member of the permitted group. Account for missing or malformed IP claims, and avoid a blanket deny rule that would also block the exceptions.
Test Microsoft 365 sign-ins from an approved IP, an unapproved IP with a permitted group member, and an unapproved IP with a nonmember. Review AD FS event logs and repeat for the relevant clients and authentication protocols.

Use Microsoft Entra Conditional Access for cloud-based location restrictions
Consider this alternative when you need a Microsoft Entra policy rather than restrictions limited to the AD FS trust.
Work with Microsoft Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface and compatibility with Microsoft Office file formats for an easier transition. It does not configure or replace AD FS or Microsoft 365 access policies.

Frequently Asked Questions
Can an allowed group member sign in from an unapproved IP address?
Yes, if the AD FS authorization logic treats membership in the permitted group as an exception. Test both a member and a nonmember from an unapproved IP before deployment.
Which IP claim should I use in the AD FS rule?
Inspect the claims available for each relevant sign-in path and use the client IP claim documented for that path. Proxy and protocol behavior can affect both the value and its trustworthiness.
What happens if a request has no client IP claim?
Define and test an explicit policy for missing or malformed IP values. If the intent is to fail closed, a request without an approved IP should be denied unless the user qualifies for the group exception.
Do AD FS rules restrict every Microsoft 365 sign-in?
No. Rules on the Microsoft 365 relying-party trust govern authentication through that AD FS trust. Review other sign-in paths and consider Microsoft Entra Conditional Access where broader cloud policy coverage is needed.




