MacOS detect multiple logged-in users

Hi we are developing a launchDeamon application and need to be notified when a new session is initiated or when a user connects to the Mac

We looked into the Notifications in Cocoa and the Security framework and couldn't get a precise number

is there any way to detect the ammount of users/sessions currently active?

need to be notified when a new session is initiated or when a user connects to the Mac

Please clarify these terms:

  • What do you mean by “session”? Are you talking about a user logging in using the GUI? Do you want to distinguish between users logged in on the console and users logged in over screen sharing? And do you care about non-GUI login sessions, that is, SSH?

  • How does that differ from “when a user connects”?

Also, what do you plan to do with this info? This matters because the best path forward depends on your final goal. For example, a daemon that’s implementing some sort of security auditing service would use a different technique than a daemon that’s tracking centralised state on behalf of these users.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  1. what i mean by session is, any login through GUI / remote access / ssh / vnc

  2. I guess they are the same

We are Developing an Zero trust access solution(you may call it a VPN), it runs as a daemon with a network extension (in some cases) The reason we need to know about the logins is to adapt our configuration based on the user requesting access, or alternatively disable ourselves when multiple users are using the machine

MacOS detect multiple logged-in users
 
 
Q