It happens sometimes that you want to run some command but you do not remember the whole syntax. Then you go to the man page to find that it has a ton of switches, you scroll to the bottom hoping to find an example you can re-use but there is none, then you Google it hoping that you won’t have to read the ton of switches. Here is my contribution for those Google searches with two useful ldap commands.
This is a simple script that connects to Active Directory, looks for a computer record and then deletes it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Quick explanation of the switches used:
-h: host to connect to
-x: simple authentication
-b: base where to start the search
-D: username to authenticate as
-w: password for that user. Seeing this should alarm you
then you put the property that the search must meet to be true
-LLL: removes the extra comments and mostly useless lines
ldapdelete is to be used with extreme caution! provide the full path of the object to delete.