Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Interapplication Communication /
Chapter 11 - Program-to-Program Communications Toolbox / Using the PPC Toolbox


Invalidating Users

It is your responsibility to invalidate all user reference numbers obtained with the StartSecureSession 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);
The DeleteUserIdentity 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 a StartSecureSession 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;

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996