Active Directory filter: mail not empty and don't ends with
<p>I'm trying to write a filter to return users that have an mail adress but don't end with @global.local. I have tried this but it don't work</p>

<pre><code>searcher.Filter = "(&amp;(objectCategory=Person)(name=*)(mail=*)(!(mail=*@global.local))(objectClass=user))";
</code></pre>

<p>This will return users with @global.local. I assume that mail=* overrides (!(mail=<em>@global.local)). If I only use (!(mail=</em>@global.local)) then I will get users with mail = null.</p>

<p>I there a way to solve this with one query? Atm I'm removing @global.local in C# after the result is returned.</p>

<hr>

<p><strong>Edit</strong></p>

<p>The above works, my problem was that I was looking at the wrong property. I should have been filtering on userPrincipalName instead of mail for the <code>@global.local</code> part.</p>