Sunday, 16 February 2014

Remove -SPManagedAccount not working

If I try to remove a particular user under Central administration->Managed accounts and click Remove button against this specific user, it gives error “The specified user or domain group was not found”.
This article is how to forcefully remove this user
First of all, why is it happening?
Reason -We have an active directory associated with the SharePoint setup with few number of users been added in the SharePoint under Central Administration->Managed Accounts. Now the user has been deleted from Active directory, however the user entry still exists under Managed accounts in Central Administration in SharePoint.
General Remedy suggested – If we use Remove-SPManagedAccount -identity  ”domain\username” command in Powershell, I receive error Remove -SPManagedAccount : The account domain\username was not found.
So how to remove this managed account forcefully in SharePoint 2010.
Go to Sharepoint_Config database and go to dbo.objects table.
In it, run the following query

SELECT Id,CAST([Properties] as xml)
From [SharePoint_Config].[dbo].[Objects] with (nolock)
Where [Name] LIKE 'managed-account%'

 
Now check each Xml under property column and identify the xml which contain the user which was deleted by Active directory but can’t be deleted by Managed accounts and Note the ID column value of the particular row.
Now go to dbo.dependencies table and run following query (please replace ID number in the query)
select * from dbo.Dependencies where
ObjectId='ID_found_in_objects_table'


If you find any row in it, you need to figure out what needs to be done for the dependencies for that user.
If there is no row in it, do back to dbo.objects and run following query (please replace ID number in the query)
Its done. The user’s entry under Managed Accounts section is removed now.
If you find this useful, Please do share your comments.
Disclaimer: I have stated my experience here. This approach might not be the recommended by Microsoft. Please check with Microsoft before using this. This should be used as the last resort and should be used judiciously with utmost care and all backups taken before starting this process

2 comments:

  1. This worked for me, thanks a lot!

    ReplyDelete
  2. Can you please send by e-mail me the code for this script or please tell me in detail concerning this script?

    TOP QUALITY Healthcare Websites Design by optimized360.com

    ReplyDelete