Code to Delete a Profile

This section shows how to delete a profile. Care must be taken when deleting a profile due to possible expression dependencies on the deleted profile.

  1. If not already connected, create a ProfileService object, oProfileService, and establish a connection to the Profile Store. For information about connecting to the Profile Store, see Code to Connect to the Profile Store.

  2. The profile object can be deleted by specifying the schema name, and either the primary key value or a key name/value pair of the ProfileObject object. The UserObject schema type has a primary key of logon_name and a join key of user_id which is a globally unique identifier (GUID). For information on the valid profile schema types, see Profile Schema. Delete the oUser1 profile created in Code to Create a New Profile.

    • Delete by specifying the primary key value and the schema name.

      oProfileService.DeleteProfile "JoeUser@microsoft.com", "UserObject"
      
    • Delete by specifying a key name/value pair and the schema name.

      oProfileService.DeleteProfileByKey "user_id", _
       "{74A38551-FFFF-FFF6-FFFF-0A20C90DC8D1}", "UserObject"
      


All rights reserved.