2

I am not a Sharepoint developer so I'm struggling quite a bit with this issue. We have items that we want to migrate to another site collection with a custom C# code. It works pretty good except for a few items which have a User field where the value contains an user that does not exist anymore in our Active Directory system.

Is there a way to handle this issue properly ?

EDIT :

We want to keep the same value for history review purpose. If the user is disabled, I can't assign the same user to the item.

It's so tightly coupled to the ActiveDirectory that I can't assign a custom value (I mean a user that was in our ActiveDirectory and is now gone).

2
  • Can you post your migration code or the error you receive when migrating an orphaned user? Commented Jan 5, 2021 at 15:38
  • @MichaelColbs I'm not sure my code would make a difference here, the error is related to the fact that the value of Author field is no longer an existing user in our ActiveDirectory.
    – Florian
    Commented Jan 7, 2021 at 14:58

3 Answers 3

2

The item should still come across with an orphaned user. However, if you want to eliminate these items, you can check to see if the user exists at the destination first before copying

using (SPSite site = new SPSite(_url))
{

    SPServiceContext ctx = SPServiceContext.GetContext(site);
    UserProfileManager _upaManager = new UserProfileManager(ctx);

    // Chek if user exists
    if( _upaManager.UserExists("domain\\user")}
    {
        // The user exists
    }
    else{
        // The User does not exists
    }
}
1
  • My question is not clear. I want to keep the same value even if the user doess not exist anymore for history review purpose. I edited the question.
    – Florian
    Commented Jan 5, 2021 at 15:27
1

I don't think that you will be able to keep a reference to the previous user as it's no longer a valid user. User fields are lookups to a hidden list within the site that contains the user information, and those users are probably no longer there for your new site so the lookup is not valid

2
  • I'm wondering how Sharepoint is able to keep a reference to the invalid user. I'm really surprised how tighlty-coupled Sharepoint is with ActiveDirectory. What you're saying is that I can't find a workaround ? How do I keep a reference for history purpose ?
    – Florian
    Commented Jan 7, 2021 at 14:56
  • 1
    Not sure, but I assume that on existing sites the hidden list still contains the record related to the account that was deleted from AD, so the lookup is still valid Commented Jan 8, 2021 at 15:34
1

not sure how it does 3rd party tools, but that is possible (like metalogix,...etc) but I think it should be first copying the underlaying hidden list of user profiles and then copying the item. that is because as Joel Rodrigues said that field is a lookup.

1
  • Tools like ShareGate will preserve the user even if it doesn't exist. Or, you can actually map it to another account if the current one doesn't exist. ie. System Account Commented Jan 7, 2021 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.