Important: The information in this document is obsolete and should not be used for new development.
Invalidating Users
It is your responsibility to invalidate all user reference numbers obtained with theStartSecureSession
function before your application quits. However, while your application remains open, you may want to keep track of a user reference number to start a session with a port, end it, and then later start another session with the same port.Use the
DeleteUserIdentity
function to invalidate the user reference number for a particular user.
err := DeleteUserIdentity (userRef);TheDeleteUserIdentity
function removes a user by invalidating the specified user reference number. Note that you cannot invalidate the guest reference number (0) and, in most cases, you should not dispose of the default user reference number.Listing 11-20 illustrates how you use the
DeleteUserIdentity
function to invalidate a user reference number obtained from aStartSecureSession
function. The sample code does not invalidate the user reference number if it is either the default user reference number or the guest reference number (0).Listing 11-20 Using the
DeleteUserIdentity
function to invalidate a user identity
FUNCTION MyDeleteNewUserRefNum(newUserRef: LongInt): OSErr; VAR err: OSErr; defUserRef: LongInt; defUserName: Str32; BEGIN IF newUserRef <> 0 THEN BEGIN {user reference number passed was not the guest} err := GetDefaultUser(defUserRef, defUserName); IF err = noErr THEN BEGIN {there is a default user} IF newUserRef <> defUserRef THEN {new user ref number isn't the default user ref num, } { so ok to delete} err := DeleteUserIdentity(newUserRef); END ELSE {there is no default, so delete new user ref num} err := DeleteUserIdentity(newUserRef); MyDeleteNewUserRefNum := err; END ELSE {user reference number passed was the guest} MyDeleteNewUserRefNum := noErr; END;