Cannot get inactive Users from SiteUsers property

Hello,

I am using export and import of lists within my sharepoint site collection. and I need to maintain users security like timestamp and author, editor. Since export, import api replaces inactive users(who left organization) by current user I have written PowerShell script to update author and editor field by getting inactive users reference. 

For users who left organization, since they are inactive now, I cannot get these users when I do SiteUsers.GetByID(ID). But I could get reference to these users using Web.EnsureUser(UserName) method since I am using the same site collection.

But today suddenly I am not able to get some users who are inactive using Web.EnsureUser method. If I run my script in other site collection, I could get that inactive user but in one particular site collection I am not able to get that user reference. Anything that I should do to get that user reference? Or any other way to retain inactive user references?

Thanks.

July 31st, 2015 2:14pm

Hi,

Please try to use the line of code below to get the inactive users.

SPUser user = web.SiteUsers[userName];

http://karthikeyansp.blogspot.com/2014/11/cleanup-inactive-users-in-sharepoint.html

Best Regards,

Dennis

Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2015 2:39am

Hi Dennis,

I tried this but no luck. I could not get inactive users using above method.

I tried to do a foreach loop in SiteUsers and displayed user names and found that most of the inactive users are not there. Is there any default timer job/user profile setting that caused this?

I think that unless we remove the inactive users from Site User Inormation List, inactive users are retained. Please guide me if I am missing anything.

One update is that we get FBA users which are inactive.
  • Edited by SuPar 20 hours 38 minutes ago
Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2015 7:01am

Thanks Ilqar,

I read the article provided by you. I checked that My Site Cleanup Job deletes user profile and my site of the user. In my case I am referring to fetch SPUser object from Web.SiteUsers. I think items in this list should not be deleted automatically. Please correct me if I am wrong.

August 3rd, 2015 7:51am

Hi,

You can also try to get the inactive users from "UserInfo" table of the content database using the following SQL query.

SELECT * FROM [Content_DatabaseName].[dbo].[UserInfo] WHERE tp_Login='DOMAIN\UserID'

More information:

http://www.sharepointdiary.com/2012/09/find-and-delete-orphaned-users-in-sharepoint.html

Best Regards,

Dennis

Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2015 9:34pm

can you get users item and properties as following?
userItem=Web.SiteUserInfoList.GetItemById(ID);		
August 4th, 2015 2:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics