|
Technote 1186How To Be a Good Multiple Users Citizen |
CONTENTSWhere is that Folder? |
This Technote describes the new APIs provided by the Multiple Users technology introduced in Mac OS 9.0. It also answers the most frequent questions from developers and provides a few workarounds for commonly encountered problems. This Note is directed at application developers who are
accessing folders within the System Folder or using the
At Ease and Macintosh Manager were previous similar products and all the information provided in this Note is also relevant for those technologies. |
Where is that Folder?
The The Multiple Users technology manages a group of
redirected folders associated with each User who may be
logged in. If the Owner of the computer is logged in, then
no redirection occurs and all folders are accessed as if the
Multiple Users technology was not there. However, if any
other User is logged in then those redirected (one of each
per User) folders are accessible with the
If you need to access the non-redirected folders (not all of them are accessible), you may do so using the following constants:
Additionally, there are new constants defined to locate the User's folders:
However, location of those special folders is unfortunately not the last word of the story...
|
Not All Users are EqualAfter the boot process completes, Multiple Users displays
a login dialog. To login, a user must have an account
(usually set up by the owner of the computer). The user may
have to enter a password to login. While the login dialog is
displayed, background-only applications (i.e., type
When the user is finished, they choose Logout from the Special menu. This begins the logout process. First, all normal applications are sent quit Apple Events until they quit. (Note that once the user has confirmed the logout, there is no way to abort it&emdash;an application will be sent a quit event every few seconds until it actually quits.) Next, a logout notification is sent to all registered programs. Finally, the Folder Manager is told to stop redirecting the per-user folders. Once logout is complete, the login dialog is displayed.
Applications usually need to write two different kinds of
data: the user data, such as documents, or user's
preferences, and application data, such as hardware
configuration, or dictionaries. The former typically needs
to be stored in one of the redirected folder, the latter
needs a non-redirected folder. The problem comes from the
fact that some environments (Limited and Panels) will forbid
write-access to all non-redirected folders but one: the
Application Support folder that you can locate through the
constant: Therefore, if your application is currently writing data in any other folder, you will have to make that change in order to be compatible with the Multiple Users technology. In particular, as with Netboot, you can't even be sure that your application's folder is going to be writable. To determine if you have write access to a given folder,
check the Or, if you prefer, do not check in advance if you can
write to a folder, but be ready to handle
You also have to pay attention to the
|
Not All Applications are EqualIf you're writing a classic Macintosh application, aside
from using But if you're writing a background-only application (type
All the following APIs are found in Folders.h. You can register for the following notifications:
Sent when a user has logged in. When you receive this
message
Sent just prior to redirecting
Sent when a user has logged out. This is the last time
Sent just after Use the following APIs to register and unregister your notifications:
Use Currently, the only option is specified by the
Use The prototype of your notification function should be:
|
This function will be called for all Folder Manager
notifications. The message parameter will contain the type
of notification (user login, user logout, etc.), the
In the case of the four notifications cited above, the
arg parameter is a pointer to a
|
struct
|
There is an additional fifth notification which is very different from the first four and will be of use only to a few developers: |
kFolderManagerNotificationDiscardCachedData |
Sent by third-party software when the entire Folder Manager cache should be flushed In that case,
|
Is Multiple Users Installed?If you wish to be more than just compatible with the
Multiple Users technology then it is crucial to know whether
it is installed on your users system of not. In order to
check, use the
Note that the result of the The current version of the
|
Is Multiple Users Running?In order to determine whether Multiple Users is active on
your users machine, check for the existence of the Multiple
Users
|
Who is Logged In?How can I tell if no user is currently logged in? You should make sure Multiple Users is active and then
look at the How can I tell if a User other than the Owner is logged in? Use the
|
User Names and PasswordsMany developers may be interested in knowing what their user's name and password are, and how secure the password is. In order to get the user name, check the
With regards to the security of the password, it is stored hashed in the Multiple User database and is never in a form that can be decrypted. If you are using any alternate password plugins, it is the responsibility of the plugin manufacturer to ensure that the information is stored securely.
|
Additional Notes & Warnings
|
SummaryTo be compatible with the Multiple Users technology,
always use the To take advantage of the Multiple Users technology,
register the new notification functions, and use the Gestalt
call with the |