3

I'd like to be able to retrieve the current user's associated Apple ID from a shell script. My first guess was to do so using dscl which I can get using my own user. But I'm not sure how reliable/consistent this method would be generally for any user.

dscl . readpl /Users/[username] dsAttrTypeNative:LinkedIdentity appleid.apple.com:linked\ identities:0:full\ name

Are there any alternative ways to do this? Maybe reading a plist somewhere using defaults read?

  • ID associated with what? It's quite possible to have more than one ID, used for different purposes. – Tetsujin Oct 5 '16 at 18:47
1

AppleIDs aren't specifically 'associated' with any given local user account - if there is an AppleID signed in on the Mac you might try using mas:

https://github.com/argon/mas

Specifically the command mas account should show you the currently logged-in AppleID.

  • That's actually not entirely true. Any user that has enabled iCloud services with their account has definitely created an association between their Apple ID and user account. There is also a specific iCloud feature that allows a user's password to be reset after first authenticating with their Apple ID. This would not be possible without some kind of association. – Wilco Oct 7 '16 at 22:49
  • All true, but that's an optional step that a local user may not have taken, which is what I was referring to. – da4 Oct 8 '16 at 13:59
  • Ah I gotcha, makes sense. – Wilco Oct 14 '16 at 1:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .