1

I need to know if the current user is being managed by Mac OS X Parental Controls (more specifically, the app age restrictions) in order to block some contents of the app. How can I do that? Any of these will be enough.

Methods that can be achieved with Objective-C, but not necessarily using Objective-C, like bash commands or AppleScript commands, are also accepted.

EDIT: The app age restriction can be found here: https://ibb.co/mOZyww

VitorMM
  • 1,060
  • 8
  • 33

1 Answers1

1

First, I'm not sure what you mean by

app age restrictions

On macOS 10.13, I only see the option to restrict applications to a whitelist; I can't configure restrictions based on age.

Anyway, parental controls are stored in the local directory services, in the mcx_attributes attribute for the user in question.

(mcx refers to the old Managed Preference framework)

You can browse this via the UI using Directory Utility or via dscl (using the mcx plugin).

If you run dscl, you can then browse the directory services using cd, ls, etc.

For example, I can navigate to my testuser:

cd /Local/Default/Users/testuser

And then dump the parental controls with mcxexport

 -mcxexport .

This will give you the configured parental controls in XML format.

Check out dscl . -mcxhelp for more information.

Updated

Toggling the "Restrict: Apps to:" setting updates this preferences key:

<key>gamesLimit</key>
    <dict>
        <key>state</key>
        <string>always</string>
        <key>value</key>
        <integer>300</integer>
    </dict>

You would have to play around with it to figure out the corresponding values (e.g. 300 == Age 12+)

TheNextman
  • 12,428
  • 2
  • 36
  • 75
  • This is what I mean with 'app age restrictions': https://ibb.co/mOZyww Sixth option. – VitorMM Jan 19 '18 at 22:35
  • I tried using `cd /Local/Default/Users/testuser` replacing `testuser` with my user short name, and I received a `No such file or directory` error. – VitorMM Jan 19 '18 at 22:36
  • I added the details of the key to my answer – TheNextman Jan 20 '18 at 02:43
  • Don't just `cd` into that path. Read my answer. Run `dscl`, which will allow you to browse directory services using commands like `cd`. – TheNextman Jan 20 '18 at 02:44
  • If you're looking for a one-liner, this form works for me: `dscl . -mcxexport /Users/testuser` – TheNextman Jan 20 '18 at 02:48
  • 1
    Your answer was the key to find what I was looking for, so thanks :) However, if someone wants to retrieve that value directly, he/she will have a more direct return using `dscl . mcxread /Users/testuser com.apple.iTunes gamesLimit` – VitorMM Feb 05 '18 at 14:20
  • 1
    By the way: `1000 => No limit`; `100 => 4+`; `200 => 9+`; `300 => 12+`; `600 => 17+` – VitorMM Feb 05 '18 at 14:21
  • 1
    Correcting myself, that command has a return easier to parse: `dscl . mcxexport /Users/testuser com.apple.iTunes gamesLimit` – VitorMM Feb 05 '18 at 15:32