Active Directory Delete AD Account

Hi I am using UiPath’s UiPath.ActiveDirectoryDomainServices.Activities and using Delete User activity but unfortunatly I am getting below error when i try to delete user account:

Unable to delete User: XXXXX. Reason: An error has occurred: The directory service can perform the requested operation only on a leaf object.

Please reach out to me if you have any solution.

Hi @pratik.gupta,
I can only guess, but you are probably trying to remove object which is not user (group or other object type). Or this object is protected from removal. You can check it by enabling “advanced view” mode in Active Directory Users and Computers and going into properties of this object. On Object tab there will be marked something like “Protect object from accidental deletion”.

1 Like

Thanks for the reply. I just checked the object tab and that checkbox was already unchecked.

Another point is that I am able to Disable the account using uipath activitiy, only Delete User activity is not working.

Can you show your DN (DistinguishedName) for you object (user) you are providing in Delete User activity. I think there might be something wrong.

Cannot share exact string due to security reasons but the format is similar to what we get normally. It goes something like this:


This is obtained using “Get Distinguished Name” activity and this same distinguished name is working fine when i try to set user status to disable.

All seems fine so far. The only thing which is left is to check if you have full permission for this node to remove anything. Is manual deletion from ADUC console working for you without any prompt for full admin password or something like that?

1 Like

I tried manually deleting the user from ADUC tool and there was a pop up which says “Object XXX contains other objects. Are you sure you want to delete all of the object it contains?”

When I click ok on this popup box the user gets deleted successfully.

But in case of uipath activity there is no such flag present where we can tell the activity to proceed with delete even if there is subtree in it.

This “Object XXX contains other objects. Are you sure you want to delete all of the object it contains?” means that it’s not user but container so you can’t treat this object with Delete User activity. Please make sure if it’s user type of object and not for example group of users.

Thanks for the reply. I will once have a look.