Not sure how to create a Smart Group using an EA with dates in the future

mm2270
Legendary Contributor III

Hi Jamf community. I've been having some trouble understanding if the following is even possible, so I thought I'd post here to see if anyone has any ideas or has tackled this in the past.

I have an EA I created, which gets the expiration date of the machine 802.1x issued certificate. It converts the expiration date into a "Jamf friendly" format, such as 2023-08-10 10:05:00. It reports that (if found) as the result in the EA.

The problem I'm having is, I want to build a Smart Computer Group that uses this information to show me any Macs that have these certificates that are going to expire in say, 30 days from now. I can't seem to use any of the built in date operators to make this work. Neither the more than x days ago or less than x days ago criteria will give me what I'm looking for. They seem to only work properly with dates in the past and not ones in the future. And the before (yyyy-mm-dd)and after (yyyy-mm-dd) options wouldn't make sense to me it seems, since these would be constantly moving targets.

It doesn't seem possible to use a future date EA and those modifiers with a Smart Group looking ahead to be proactive.

I think I may need to rework my EA to convert the date in a way that it calculates at the time of execution how many days are left from current time until the cert expires, and have that be the output (as an integer).

I'm open to any other ideas though.

1 ACCEPTED SOLUTION

sdagley
Esteemed Contributor II

@mm2270 Short of getting Jamf to implement operators for dates in the future having the EA convert the future date to number of days seems like it's the cleanest approach. The ugly alternative is to have your EA invert the future date into a past date, so you can use the "less than x days ago" Smart Group criteria to find certs expiring in the window you're interested in.

View solution in original post

4 REPLIES 4

sdagley
Esteemed Contributor II

@mm2270 Short of getting Jamf to implement operators for dates in the future having the EA convert the future date to number of days seems like it's the cleanest approach. The ugly alternative is to have your EA invert the future date into a past date, so you can use the "less than x days ago" Smart Group criteria to find certs expiring in the window you're interested in.

mm2270
Legendary Contributor III

Hey @sdagley thanks for the reply! And thanks for confirming what I'm guessing is the truth - that using those date operators the way I was hoping isn't possible without Jamf making it a possibility.

Oddly enough, I had actually consider what you proposed, of inverting the date into some date in the past, but besides being a level of hackery I don't feel comfortable with, I think it would be prone to issues and false positives.

I'll just go with the more sane option for now of converting it into a days left integer and then building my smart group from that.

Thanks again!

sdagley
Esteemed Contributor II

@mm2270 yeah, inverting the date so you can use the less/more operator as a past dates would just make my brain hurt every time I saw it. Please post if you create a Feature Request as I'm surprised more people haven't asked about this before.

And this all reminds me I should dig up the FR I submitted to support comparison operators between two EAs as a Smart Group criteria because I hit another use case for it today

mschroder
Valued Contributor

A Feature Request is certainly a good idea, but it will take forever. In the meantime you might just subtract 10 years from the date and then use the less than operator. Certainly not nice, but should work.

 

I use 9.9.1999 as a date for an event that never happened, but I'm happy I don't need to do math with it ;)