ChangeOwner method of the Win32_UserProfile class

Changes the owner of a user profile to a different user.

Syntax

uint32 ChangeOwner(
  [in] string NewOwnerSID,
  [in] uint32 Flags
);

Parameters

NewOwnerSID [in]

The SID of the new owner of the profile.

Flags [in]

Bit flags to replace or delete a profile. This parameter can be set to one or more of the following values.

Value Meaning
ReplaceNewOwnerProfile
0
If the new owner already has a profile, calling the ChangeOwner method with this flag replaces the existing profile. If the new owner already has a profile, calling this method without this flag fails and returns HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS).
DeleteReplacedProfile
1
If the new owner has a profile and ReplaceNewOwnerProfile and DeleteReplacedProfile properties are specified, the replaced profile is deleted. If DeleteReplacedProfile is not set, the replaced profile is unchanged. The profile is not deleted, not enumerated, and no user automatically uses the replaced profile. If ReplaceNewOwnerProfile is not specified, this flag has no effect.

Remarks

Because the ChangeOwner method modifies the SID of the user profile, the user of the WMI object must perform one of these steps when using this method

  • Call ChangeOwner, and then reinstall all apps.

    Note

    If this step is taken, access control lists (ACLs) may contain incorrect settings.

  • Remove all apps before calling ChangeOwner, and then reinstall those apps after the call.

    Note

    This step is the cleaner solution, but app state and settings may be lost.

Examples

To use Win32_UserProfile to migrate a user to a new domain, see the following Vista s MoveUser.exe replacement article on TechNet.

Requirements

Minimum supported client
Windows Vista with SP1
Minimum supported server
Windows Server 2008
Namespace
Root\CIMV2
MOF
UserProfileWmiProvider.mof
DLL
Profprov.dll

See also

Win32_UserProfile