Partager via


Remove Deleted Users

Have you ever had a time when you quickly and without thinking too much or accidentally deleted the user objects (that you know are no longer needed) in Active Directory and then you said, 'Shoot, now I have some records in MPS database referencing an object that no longer exist in the Active Directory? If yes, keep reading.

For most parts, it is probably not going to affect anything until you want to remove that organization from your environment or you want to remove the mailsotre resource from the environment and you realize there are still objects consuming the resource but you can't remove them.

Now, the above assumes that those objects that you have deleted are no longer needed. If they are needed still, then you should look at how to authoritatively restore the Active Directory for that object instead. If not, then you can run the following procedure and this procedure will attempt to remove the mailbox resource management tied to that GUID as well as the Customer records in the Customer table in the PlanManager database. Please note that, this is provided "AS IS" with no warranties, and confers no rights. Use of the included samples are subject to the terms specified in the Terms of Use. And, you should know that you are using at your own risk. If you are not sure, please contact Microsoft. Also, this is applicable to HMC 4.5 only.

<request>
<data>
    <preferredDomainController>ad01.hmc45.com</preferredDomainController>
</data>
<procedure name="DeleteDeletedUser" description="Delete a user and associated resource allocations" access="private" type="write" perfEnabled="0" saveDataForRollback="0" auditEnabled="0">
    <procedureData>
        <junkyard/>
        <GUID>535966DB27CD494597DDC2C1BC7816F3</GUID>
    </procedureData>
   
    <before source="data" destination="procedureData" mode="insert"/>
    <execute namespace="Exchange 2007 Resource Manager" procedure="DeallocateMailbox" impersonate="1">
    <executeData/>
        <before source="procedureData" sourcePath="GUID" destination="executeData" destinationPath="GUID" mode="merge"/>
        <before source="data" sourcePath="preferredDomainController" destination="executeData"/>
    </execute>

    <execute namespace="Managed Plans" procedure="DeleteCustomerByGUID" impersonate="1">
        <before source="procedureData" sourcePath="GUID" destination="executeData" destinationPath="GUID" mode="merge"/>
        <before source="data" sourcePath="preferredDomainController" destination="executeData"/>
    </execute>
</procedure>
</request>

Now, obviously the problem here is that you need to provide the GUID and you can't find the GUID from the Active Directory (because the object has already been deleted). So, you will need to find the GUID from the PlanManager database itself instead. To do that run the following SQL query,

     Select REPLACE(CustomerID,'-','') AS GUID, CommonName, FROM [PlanManager].[dbo].[Customers] WHERE StatusTypeCode = 'EN' and CommonName is like '%<username/email>%' 

Replace the above highlighted <username> with your the appropriate value and then it execute the above query. That should return the records matching and if multiple records returned, then find the one that matches to the user object you just deleted. Take the GUID column and use that value fro the above.

It is important you are ABSOLUTELY sure that this is the right value because if not, you may be removing the wrong record. So, please use the above at your own risk. To confirm the deletion is good, run the following,

     Select REPLACE(CustomerID,'-','') AS GUID, CommonName, FROM [PlanManager].[dbo].[Customers] WHERE  REPLACE(CustomerID,'-','')  = '535966DB27CD494597DDC2C1BC7816F3'

The record returned should have a StatusTypeCode = 'DE'.

Coming up next, a script that helps you to determine if there is any MPS to AD Integrity problem.

Comments