Azure Active Directory has the ability to create Security Groups with Dynamic membership. This is great if you can apply logic to a group, as members will fall in and out of scope without any work required.
Microsoft have a great writeup on how it all works and how to create rules, however I’ve run into a scenario not covered in the documentation.
If you create a Dynamic membership rule and want to include only attributes that have no value, the term ‘null’ works fine. You can create your group or modify the rule without issue.
However, if your binary operator (the equals part in the example above) is set to ‘not’, it won’t work.
The use case I had for ‘not null’ was to have a group of users which only had employee numbers, which was an easy way of filtering out test accounts, service accounts and so on.
You’ll get this error:
Note that you can’t do this from the simple rule view, changing ‘null’ to ‘$null’ there results in the code looking like this:
(user.extensionAttribute1 -eq “$null”)
Where it should look like this, without the quotes:
(user.extensionAttribute1 -eq $null)
A simple fix, but something that’s not documented on the support page. Hope this helps anyone who runs into the same problem.
6 thoughts on “Null Dynamic Membership Rules in Azure Active Directory”
Thank you! This resolved my issue. I was trying to do something similar… only grabbing accounts where the JobTitle was not blank. I had been using (user.jobTitle -ne “”). It was accepted but ignored. (user.jobTitle -ne $null) did the trick!
Awesome, glad it helped :)
Awesome, glad to hear it :)
Thank you very much! This is exactly what I needed. I don’t understand why there is not “notempty” operator or why they didn’t document this.
For me, it didn’t work with -not $null but it worked with -ne $null
Thanks, this solved my issue. And Agreed, there should be a ‘nonempty’ operator. ;-)
Hey people, I just tried the above example and it didn’t like it. Perhaps MS has changed the rules.
This is the example MS provided to base a query on NOT NULL.
-not (user.extensionAttribute1 -eq null)
My Example was to get “All Contractors” that “Have a TelephoneNumber”:
(user.extensionAttribute4 -eq “Contractor”) -and -not (user.TelephoneNumber -eq null)
Worked a treat :)
Thanks for sharing this content :)