Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

AFP Login

To make use of any resource managed by a file server, the AFP client must first log in to the server. This section provides an overview of the AFP login process.

After a user selects an AFP server to log in to, the AFP client sends the FPGetSrvrInfo command to request information about that server. The server returns information that includes

During the AFP login process, the AFP client tells the server which AFP version the client will use to establish the connection and which UAM it will use to authenticate the user.

Each AFP version is uniquely described by a string of up to 16 characters called the AFP version string. The AFP version strings for the AFP versions supported by AFP 3.x are listed in Table 1-12.

Table 1-12  AFP version strings

AFP version

AFP version string

AFP 2.1

AFPVersion 2.1

AFP 2.2

AFP2.2

AFP 2.3

AFP2.3

AFP 3.0

AFPX03

AFP 3.1

AFP3.1

AFP 3.2

AFP3.2

The UAMs supported by AFP 3.x and their corresponding strings are listed in Table 1-13.

Table 1-13  AFP UAM strings

String

UAM name

No User Authent

No User Authentication UAM. For details, see “No User Authentication.”

Cleartxt Passwrd

Cleartext Password. For details, see “Cleartext Password.”

Randnum Exchange

Random Number Exchange. For details, see “Random Number Exchange.”

2-Way Randnum

Two-Way Random Number Exchange. For details, see “Two-Way Random Number Exchange.”

DHCAST128

Diffie-Hellman Key Exchange. Allows the client to send a password of up to 64 bytes to the server through a strongly encrypted “tunnel.” This type of encryption is useful for servers that require the use of cleartext password. For details, see “Diffie-Hellman Key Exchange.”

DHX2

Diffie-Hellman Key Exchange 2. Allows the client to send a password of up to 256 bytes to the server through a strongly encrypted “tunnel.” This type of encryption is useful for servers that require the use of cleartext password. For details, see “Diffie-Hellman Key Exchange 2.”

Client Krb v2

Kerberos. Allows the client to use Kerberos v4 and Kerberos v5 tickets to authenticate a user.

Recon1

The Reconnect UAM. Allows the client to use the FPLoginExt command to reconnect using a reconnect token (also known as a credential) containing all of the information required to authenticate.

The prospective AFP client initiates the login process by sending an FPLogin or an FPLoginExt command to the server. Both commands include the AFP version string and the UAM string that the client has selected. Depending on the selected UAM method, the FPLogin or FPLoginExt command may include user login information (such as a user name or password), or a subsequent FPLoginCont command may include such information. The sending of additional FPLoginCont commands may be required to complete user authentication, as described in the next section, “File Server Security.”

If the UAM succeeds, an AFP session between the AFP client and the server begins.

As mentioned earlier, in addition to the AFP and UAM versions that the server supports, the FPGetSrvrInfo command returns a Flags parameter whose bits provide additional information about the server that is useful to an AFP client. The bits of the Flags parameter are listed in Table 1-14.

Table 1-14  Bit definitions for the Flags parameter returned by FPGetSrvrInfo

Constant and bit position

Description

kSupportsCopyFile (bit 0)

Set if the server supports the FPCopyFile command.

kSupportsChgPwd (bit 1)

Set if the server supports the FPChangePassword command.

kDontAllowSavePwd (bit 2)

Set if the client should not allow the user to save his or her password for volumes mounted at system startup. The item-selection dialog box may still allow the user to save his or her name. However, when this bit is set, the button offering that option is not displayed.

kSupportsSrvrMsg (bit 3)

Set if the server supports the FPGetSrvrMsg command.

kSrvrSig (bit 4)

Server supports server signatures, which is a 16-byte number that uniquely identifies the server. An AFP client should use the server signature to ensure that it does not log in to the same server multiple times. Preventing multiple logins is important when the server is configured for multihoming.

kSupportsTCP (bit 5)

Set if the server supports TCP/IP.

kSupportsSrvrNotify (bit 6)

Set if the server supports server notifications.

kSupportsReconnect (bit 7)

Set if the server supports the FPGetSessionToken and FPDisconnectOldSession commands.

kSupportsDirServices (bit 8)

Set if the server supports Open Directory.

kSupportsUTF8SrvrName (bit 9)

Set if the server supports server names in UTF-8 encoding.

kSupportsUUIDs

Set if the servers supports Universal Unique Identifiers (UUIDs).

In this section:

Reconnecting Sessions
Recovering From a System Crash
Disconnect Timers


Reconnecting Sessions

If an AFP session is disconnected due, for example, a network outage, but the AFP client still has the required information, the AFP client can reconnect the session.

Clients that use the Reconnect UAM, described in “Reconnect,” follow these steps to reconnect:

  1. Log in successfully by calling FPLoginExt using a UAM that provides a session key.

  2. Call FPGetSessionToken to get a token, specifying the Type parameters as kRecon1Login (5).

  3. Periodically call FPGetSessionToken with the Type parameter set to kReconn1Refresh (7) to refresh the token before it expires.

  4. If a disconnect occurs, call FPLoginExt to log in again, specifying the Reconnect UAM as the UAM, and passing the current token obtained by calling FPGetSessionToken in step 2 or 3. The reconnect token contains all of the user name and password information required for the server to authenticate the client, so logging in again does not require the client to repeat the authentication steps that took place in step 1.

  5. If the login in step 4 completes successfully, call FPDisconnectOldSession and pass the token obtained in step 2. If the server can find the previous session identified by the token, it will transfer all the previous session’s open files and locked resources to the new session and return a result code of kFPNoErr.

Clients that don’t use the Reconnect UAM follow these steps to reconnect:

  1. Log in successfully by calling FPLogin or FPLoginExt.

  2. Call FPGetSessionToken to get a token.

  3. If a disconnect occurs, log in again using the same UAM, user name and password that were used in step 1.

  4. Call FPDisconnectOldSession and pass the token obtained in step 2. If the server can find the previous session identified by the token, it will transfer all the previous session’s open files and locked resources to the new session and return a result code of kFPNoErr.

In either case, if the reconnect fails for any reason, the client must start over by logging in again as in step 1. The client should call FPDisconnectOldSession and send the current token to tell the server that it can free resources that were locked up by the earlier session.

Note: The FPDisconnectOldSession command will fail if the server cannot find the previous session or if the AFP client does not use same information to log in again. For security reasons, the server also fails all reconnects if the user originally logged in as the Guest user.

If the server returns a result code other than kFPNoErr, the AFP client can attempt to reopen its files. If the files were previously opened without Deny Modes and the AFP client did not apply byte range locks, the client should be able to reopen those files. In this case, reconnect is also deemed successful. If the reconnect is not successful, an AFP client can take the steps described in the next section, “Recovering From a System Crash.”

Recovering From a System Crash

If an AFP session is disconnected and the client reconnect information is lost due to a local system crash, the AFP client will not be able to reconnect the session. If the server allows reconnect, any files that were left open on the remote server when the local system crashed will be saved but will not be available for opening until the reconnect timeout expires. This also applies to the case where a sleeping AFP client fails to wake up or crashes and the server is saving the information until the sleep timeout expires.

To tell the server to close files left open by an old session and disconnect that session, an AFP client that supports AFP 3.1 and later can create and save a unique client-defined identifier and use the FPGetSessionToken command to send it the server. The client must do this before the local system crashes, for example, as part of its login sequence. When it receives the identifier, the server associates the identifier with the current session.

Later, if the local system crashes and is restarted, the AFP client can log in and send the FPGetSessionToken command again, this time telling the server to look for a session having the specified identifier. If the server finds such a session, it closes the files that are associated with it, frees any other associated resources, and disconnects the old session.

Note: For security purposes, before disconnecting the old session, the server verifies that the same login information was used to log in from the same system. For security purposes, the server also fails FPGetSessionToken if the user originally logged in as the Guest user.

Disconnect Timers

In previous versions of AFP, there was only one timer for determining whether a disconnect had occurred. With 10.2.x, there are two timers for determining disconnections:

If the client has an outstanding request to the server and has not received any data (including tickles) from the server, the client waits until the active timer expires before assuming that a disconnect has occurred.

If the client has no outstanding requests to the server, the client waits until the idle timer expires before assuming that a disconnect has occurred.

Special considerations arise when the system is awakening from sleep:

If the client is connected to an AFP 2.x server, the Active time and the Idle timer are both set to 120 seconds.

Note: The check_afp.app plist contains an option that can be set to disallow idle sleep if an AFP volume is mounted.

In all situations, after a disconnect, if the server supports reconnect, reconnect is started.



< Previous PageNext Page > Hide TOC


Last updated: 2006-04-04




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice