Agile Insider Blog

Importing and Deleting User Profiles in Sharepoint;Filtering Disabled Users from Import; Managing MySite of Deleted Users

We use SharePoint daily to collaborate as a team. If you are looking for additional help beyond this post, leverage Agile IT for your SharePoint consulting/deployment needs.

Note: I will touch on several related areas in this post, so I apologize if I jump all over the place.  All buckled in?  Let’s go!

Ideally, in SharePoint, you have profiles (and maybe My Sites) for users that actually use the site (or that you want to search).  For the most part, you do not want profiles of users that are disabled in Active Directory, users who have left the company, etc.

Most of the work that y0u do with profiles as an Administrator is within the SSP, under “User Profiles and My Sites”.

[Importing SharePoint Profiles Without Disabled Users or Specific Group]

By default, when setting up Profile Import, SharePoint imports all users from your current domain.  This is fine as a default, but you may end up pulling profiles that are not needed and/or wanted in two cases (off the top of my head):

1) You have a bunch of user/service accounts that are disabled in Active Directory.

2) You only want accounts from a particular group or OU to be imported into your SharePoint profiles.

In either of these cases, you will have to customize the LDAP query that SharePoint does on the backend to pull users out of AD. By default, the query searches for (&(objectCategory=Person)(objectClass=User)).  In other words “Pull all users”.

SharePoint does not distinguish whether they are active or not.  KB 827754 gives us the modified query we need to use if only pulling active users:

(&(objectCategory=person)(objectClass=user)( !(userAccountControl:1.2.840.113556.1.4.803:=2)))

If you want to import users just from a particular group or OU, the query will look something like:

(&(objectCategory=Person)(objectClass=User)(memberOf=[distinguished name of the group]))

Wayne Hall’s post here is the definitive source on how to find the Distinguished Name of the group you are looking for, and how to write the query.  If you want to go completely buck-wild, you can read all about LDAP Search Query Syntax on MSDN.

All right.  Now if you ran the full profile import before modifying the query, and have a bunch of disabled users in AD, or imported all AD users instead of a specific group, those extra profiles now exist in SharePoint where they are not doing a lot of good.


[Deleting Sharepoint Profile of Deleted Users]

How can you delete them?

The answer is that you have to do a Full (not incremental) profile import.  This does not delete the users, but marks them as “Profiles Missing from Import”.  On the “User Profiles and Properties” page of the SSP, click on “View User Profiles”

From here, there is a drop down box that lets you choose between “Active Profiles” and “Profiles Missing from Import”

Don’t laugh at the difference between my Total number of user profiles and Number of active user profiles in the picture below.  Long story, no happy ending 😉

In any case, if you select “Profiles Missing from Import”, it will show all profiles that exist in SharePoint that did NOT get pulled/updated from AD in your last full crawl.  This could be because someone left the company, or because your modified query now pulls less people.  In any case, once you verify that that user no longer exists (or shouldn’t have a profile on the server), check the box next to their profile/account name and hit delete.  You can also wait for SharePoint to run three full (not incremental) imports, after which it will delete the profiles on its own.

[Using Role Based Permissions]

A few other considerations to be aware of…  If the user is no longer with the company, but somebody explicitly assigned them permissions to a site, list, or library… they will continue to have permissions if they ever come back (This is an issue at Microsoft as vendors may do work for one team and then come back some months later to do work for another team using the same AD account).  Removing explicit permissions is a manual process (and is the reason why explicit user permissions should be the exception and not the rule).  Use (and do not break) permission inheritance where ever possible.  I usually put Active Directory groups within SharePoint groups, and assign SharePoint permissions to SharePoint groups.  That way, if any given person joins or leaves the company, I assign/remove them from the appropriate AD group and their permissions accordingly come or go in SharePoint.

[Automatic Delegation of MySite of Deleted Users]

The other consideration is My Sites.  How do you delete My Sites that belong to people that left the company?  Once SharePoint no longer has a profile for a user with a My Site (see above), it will (by default) send an e-mail to that user’s Manager (assuming their profile has a manager listed) saying:

The My Site of Joe Blow is scheduled for deletion. As their manager you are now the temporary owner of their site. This temporary ownership gives you access to the site to copy any business-related information you might need.

The manager is then added as the secondary site collection administrator for the user’s My Site, and any important documents can be copied off before the My Site is deleted.  The wording of the e-mail itself is hardcoded and the wording cannot be changed.  As well, this My Site cleanup is NOT part of or related to the “Site Use confirmation and deletion” feature of SharePoint.  It takes place as part of the “My Site Cleanup Job” which runs hourly (you can find it under Central Administration –> Operations –> Timer Job Definitions).  There were some problems with this job in RTM, but they were fixed in SP1 (in case you are still running RTM and old My Sites are still hanging around).


I hope the information above helps someone if they ever end up trying to figure out how to clear out 75,000 profiles from a SharePoint server that is only used by a few hundred people 🙂 (yes, I think I am the very definition of an edge case)


The Sean Blog : SharePoint Profile Cleanup

Learn more about our SharePoint consulting/deployment services.

Leave a comment

Learn More Today

Have questions or want to learn more about the services and solutions Agile IT has to offer?

Schedule a call with us today!

Schedule a Call

Request a Quote