3

I am trying to get SharePoint to create an SPUser for a disabled active directory account.

The reason for this is that I am archiving items across site collections. As the items are copied I am creating the users on the other site collection so that it can still have the appropriate "Created By"/"Modified By". The problem I'm having is that some of the users are long gone and their accounts are now disabled so the SPList.EnsureUser() function does not work. My current work around for this is to create an SPGroup with the users name as a place holder.

The only other person that I have seen ask this question is here: http://social.technet.microsoft.com/Forums/sharepoint/en-US/ba184fb0-a22a-4d4a-8734-5b7f14d71c85/sharepoint-api-add-user-in-sharepoint-which-is-disabled-on-active-directory-but-in-case-of-ui-its in which case the answer just re-stated that ensureUser only works on active accounts and gave a dead link.

Is it possible to create an SPUser for the disabled account or am I chasing a ghost?

1

One of the options is to 'fake' the accounts. Basically you need to extend your authorization to additional source and create your old accounts there. In one project I used 'Forms Authentication' and SQL database for user data. I created all the 'fake' users there. In my case they were users without computer access. It is not too complicated to setup and IMHO this is the best way if you are dealing with lot of users.

Other option (if you already have your users in AD) is to temporally enable them, import them in SharePoint with SPWeb.EnsureUser and disable them once import is done.

And I do like your solution with 'fake' SPGroup - it is nice and simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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