none
SharePoint 2013 on premise - Deleted users still appearing in _api/web/SiteUsers

    Question

  • I have observed that deleted user is still getting listed in _api/web/SiteUsers.

    When I do _api/web/SiteUser, deleted users are also returned but I don't want to get the deleted users

    Can someone clarify me whether it is the Sharepoint behaviour to list all the users (deleted also) when we do _api/web/site users and if so, what is the reason behind it

    Is there any other way to  restrict getting the deleted users (I'm not in favour of getting all the users using _api/web/<g class="gr_ gr_647 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="647" id="647">siteuser</g> and then checking for each user's permission to determine if the user is deleted/active or loop through all the user groups to get the active users)



    • Modifié DamodarR lundi 4 juin 2018 06:36
    vendredi 1 juin 2018 12:16

Toutes les réponses

  • SharePoint has no concept of 'active users'. As long as they are not marked as deleted manually (or through an automated process; 3rd party tools like Metalogix ControlPoint offer this) via /_layouts/15/people.aspx?MembershipGroupId=0, they will always show up on the Site Collection regardless of their Active Directory (or other user store) status.

    Trevor Seward

    Office Servers and Services MVP



    Author, Deploying SharePoint 2016

    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    vendredi 1 juin 2018 14:47
    Modérateur
  • how exactly you deleted your user? Note that each site collection has own users collection (SPUser), i.e. if user is deleted in 1 site collection this user may still remain in other site collections. So when you call API in context of 1st site collection:

    http://example.com/sites/sitecol1/_api/web/SiteUsers - it may not return deleted user

    But if you call API in context of 2nd site collection:

    http://example.com/sites/sitecol2/_api/web/SiteUsers - user may be returned.

    In order to remove user from all site collections you need to go through them and delete users in all of them. Something like that:

    $wa = Get-SPWebApplication $url
    foreach ($site in $wa.Sites)
    {
        $userToDelete = null
        foreach ($user in $site.RootWeb.SiteUsers)
        {
            if ($user.LoginName.ToLower() -eq "{loginName}")
            {
                $userToDelete = $user
                $break
            }
        }
    
        if ($userToDelete -ne $null)
        {
            $userToDelete.Delete()
        }
    }


    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - https://github.com/sadomovalex/camlex

    vendredi 1 juin 2018 14:57
  • Hi,

    After you thoroughly deleted the users from the User Information list either via PS Script or through People.aspx, try this stsadm command.

    You should ensure your UPS Application up and running before running this command (old way, yet useful), It won't delete the UPS application's database instead it will sync and update the all site collection user information list.

    Stsadm.exe –o sync –deleteolddatabases 0

    And try these timers jobs are running without any problem and let us know.
    User Profile to SharePoint Full Synchronization(Hourly)
    User Profile to SharePoint Quick Synchronization


    Murugesa Pandian MCSA,MCSE,MCPD

    Gear up for some solid action by doing. Slide,theory and blog won't useful much. 
    After all world likes only doers not sayers/speakers .

    samedi 2 juin 2018 06:10
  • I'm deleting the user manually (Going to the group where the user is added)

    I have initially added the user in sitecol1 and when I do _api/web/SiteUsers, I can see the user I have added

    Then, I have deleted the user from sitecol1  and did _api/web/SiteUsers on sitecol1, I can still see the users I have deleted.

    lundi 4 juin 2018 06:40
  • Hi DamodarR,

    You need to delete the user from user information list of the site collection.

    Go to http://siteUrl/_layouts/15/people.aspx?MembershipGroupId=0. From here, you can delete a user from the Site Collection.

    Then When you do _api/web/SiteUser, deleted users will not be returned.

    Reference:

    https://www.brightwork.com/product-blog/how-to-remove-a-user-completely-from-a-site-collection#.WxUFrGYUmM8


    Best Regards,

    Lisa Chen


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.


    lundi 4 juin 2018 09:30
    Modérateur
  • Hi DamodarR,

    Is there anything update?

    Best Regards,

    Lisa Chen


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    jeudi 14 juin 2018 10:29
    Modérateur