Platform SDK: Active Directory, ADSI, and Directory Services

Moving Users

Users can be moved within a domain.

However, you can only move objects between domains using the movetree.exe utility. When a user is moved to a different domain, the objectSID is changed to reflect the new domain and the old objectSID is added as a value to the sIDHistory property. The objectGUID remains the same.

To move a user

  1. Bind to the user to move and get an IADs pointer.
  2. Get the ADsPath using the IADs::get_ADsPath method. The ADsPath will be used to specify the user to move.
  3. Bind to the container object where you want to move the user to and get an IADsContainer pointer.
  4. Move the user using the IADsContainer::MoveHere method.

    If you have a pointer to the user object before it was moved, the pointer to the object is still valid, but the object's methods are no longer valid since the directory object it represents is no longer valid.

For sample code for moving objects, see Moving Groups.