I tried to find the correct API for getting the current MDM enrollment status on macOS but I can't find anything other than people suggesting command line tools. Unless you're an MDM application yourself, I don't think there is an official API.
The Windows API was very easy to find. Generally if he can call an executable that can fetch that MDM status, it is almost certain that executable calls some function in some library to get it.
I was curious so I checked, it uses CPProfileManager and CP_GetManagementStatus, a private undocumented MacOS API. That's one hostile OS, at least Microsoft was forced by court to open its APIs
The Windows API was very easy to find. Generally if he can call an executable that can fetch that MDM status, it is almost certain that executable calls some function in some library to get it.
I was curious so I checked, it uses CPProfileManager and CP_GetManagementStatus, a private undocumented MacOS API. That's one hostile OS, at least Microsoft was forced by court to open its APIs