I've written some code but not works it throws Exception "An operations error occurred." code --->
DirectoryEntry dirEntry = new DirectoryEntry("LDAP path", "admin-username", "admin-password");
dirEntry.Properties["member"].Remove("username-delete");
dirEntry.CommitChanges();
dirEntry.Close();
give me some ideas to get out of this things..
1) To delete an Active directory domain user account, open the Active Directory Users and Computers MMC snap-in, right click the user object and select “Delete” from the context menu. Click “Yes” is the dialog box “Are you sure you want to delete this object?” to confirm the deletion.
The Remove-ADUser cmdlet removes an Active Directory user. The Identity parameter specifies the Active Directory user to remove. You can identify a user by its distinguished name (DN), GUID, security identifier (SID), or Security Account Manager (SAM) account name.
When you delete Active Directory/LDAP user accounts in Active Directory/LDAP, those user accounts remain on the Users page in the Admin Portal but they can no longer access CyberArk Identity Connector.
When you are already using a DirectoryEntry there is no need for PrincipalContext or UserPrincipal.
You can simply use the DeleteTree()
method:
DirectoryEntry dirEntry = new DirectoryEntry("LDAP path", "admin-username", "admin-password");
dirEntry.DeleteTree();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With