I've been asked to create a solution which detects the dead accounts and cleans it up from a SharePoint site.

I found a code snippet here (in the comments) which checks each user against the AD and cleans up the account. But the LDAP details are hardcoded in the code. What happens if i want to detect it dynamically and check the dead accounts? Is there a more elegant solution to do this?

Any ideas?


Of course, the LDAP details should be a parameter.

As the linked example is a Windows forms app, this could be a text box on the form. If it was a command-line app, then a command line argument.

I'm not sure what you're looking for in terms of elegance. If you want the app to work out which Active Directory domain it's running within without needing to specify a parameter, then a better place for this question is Stack Overflow. However that will restrict you from being able to search certain parts of AD for these accounts.


Generally, there are two reasons why obsolete users or groups can exist in the SharePoint Server 2010 user profile store:

-Obsolete users: The My Site cleanup timer job is not active. The User Profile Synchronization timer job marks for deletion users who have been deleted from the directory source. When the My Site cleanup job runs, it looks for all users marked for deletion and deletes their profiles. Respective My Sites are then assigned to the manager for the deleted user and an e-mail message notifies the manager of this deletion.

-Obsolete users and groups: Users and groups that were not imported by Profile Synchronization exist in the user profile store. This can occur, for example, if you upgraded from an earlier version of SharePoint Server and chose to only synchronize a subset of domains with SharePoint Server 2010.

Here is how you would do it in PowerShell: http://iedaddy.com/2012/02/sharepoint-2010user-information-lists-and-user-profile-cleanup/

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.