SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My network admin have deactivated a lot of users from the Active Directory, and recreated them using the same username but with a different OU, Now the SP 2010 does not recognize these users or their Permissions unless i manually Remove them from the "Members" group i created and manually add them back (then they get recognized noticeable by their display name changing).

Since i have a lot of different site collections which these users can be in any one of them i tried using the object model to go through all the site collections under the web application and remove and re-add each user permissions like so:

SPSite site = new SPSite("http://localhost:47700/Divisions/100/");
SPWebApplication webApp = site.WebApplication;

foreach (SPSite currentSiteCollection in webApp.Sites)
    // user is struct i created to keep the user info.
    List<user> members = new List<user>();

    SPWeb web = currentSiteCollection.RootWeb;

        SPGroup membersGroup = web.SiteGroup["Members"];

        foreach (SPUser currentUser in membersGroup.Users)
            user userData;
            userData.login = currentUser.LoginName;
   = currentUser.Email;
   = currentUser.Name;
            userData.notes = currentUser.Notes;


        foreach (user currentMember in members)


        foreach (user currentMember in members)
            membersGroup.Users.Add(currentMember.login,,, currentMember.notes);

    catch (Exception ex)
    throw ex;

For some reason it dosen't work. Does anyone have any idea why it doesn't work? How to make it work? or any better idea of how to to it?

Thanks in advance, Itay.

share|improve this question
If they physically deleted the users from AD and then added them new again then the issue you are facing is not that the OU changed, it is that the SID changed and these are, for all intents and purposes, completely new users despite having the same user name. You will have to resync your User Profiles in order to pick up the 'new' users but I'm not sure how it will handle the old login names but with a different SID. Perhaps someone with more UPS background can assist. – Dave Wise May 3 '13 at 14:23
up vote 1 down vote accepted

Dave is right. You might can try to use the migrateuser functionality to see if that will fix the sids for you. Stsadm or powershell

share|improve this answer
It worked except for one weird problem described Here – Itay Weiss May 4 '13 at 17:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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