如何通过LDAP过滤Exchange默认系统用户?
Absolutely, you can filter out those Exchange default system users by targeting their distinct naming patterns in your LDAP query. Here are a couple of reliable approaches:
Approach 1: Exclude by Username Prefixes
Looking at your list of system users, they all follow specific naming conventions (like starting with SystemMailbox, Migration., etc.). You can build an LDAP filter that excludes users matching these patterns while keeping regular user accounts:
(&(objectClass=User) (!(name=Exchange Online-*)) (!(name=SystemMailbox*)) (!(name=DiscoverySearchMailbox *)) (!(name=Migration.*)) (!(name=FederatedEmail.*)) )
Breakdown of the Filter:
(objectClass=User): Keeps the base condition to only retrieve user objects- Each
!(name=PREFIX*): Uses the NOT operator (!) to exclude any user whosenameattribute starts with the specified prefix. The*acts as a wildcard to match any characters following the prefix.
This filter will exclude all the system accounts you listed and retain your regular users like Zeynep Demir, Mustafa Demir, etc.
Approach 2: Filter Using Additional Attributes (Optional)
If you have access to other user attributes, you can add extra checks for more precision:
- Some system accounts might have a
userAccountControlvalue that marks them as disabled (though not always, so this isn't 100% reliable) - You could also filter for users with a valid, non-system email address (e.g.,
(mail=*@yourdomain.com)), but this depends on your environment's setup.
The prefix-based filter is the most straightforward and reliable for your specific case since it directly targets the naming patterns of the system accounts you identified.
内容的提问来源于stack exchange,提问作者Utku

