Using a .csv file I need to bulk delete contacts using ldifde

I have a csv file with account names and I need to create an ldifde import file and bulk delete these contacts in windows server 2003 active directory.
In summary, how to I get the .csv file converted to an ldifde file?
LVL 15
Who is Participating?
Joseph DalyConnect With a Mentor Commented:
So you take your csv file and exrtract out the user names paste them into a notepad document so they look like below. Save the file as whatever you like and modify the docname.txt file to reflect that.

What that script does basically is loops through the text file and each line it queries the username and if found will move that user to the new OU you created for this purpose. It will then loop back to the second line and continue this process.

One thing to note is make sure you dont have any spaces at the end of the line.

Open in new window

Joseph DalyConnect With a Mentor Commented:
Well I dont know if its the best way of doing it but you could do a two step process using dsquery, dsmove and dsrm.

Basically what you would do is select all of your user account names and copy them to a simple text file. Then using the script below you can move them all to a new ou created for this purpose. Once they are there you can just select them all and delete them.

for /F "tokens=1" %%h IN (docname.txt) Do dsquery user -samid "%%h" | dsmove -newparent {new out distinguished name}

Open in new window

minvisConnect With a Mentor Commented:
Use "CSV to LDIF converter" (
Then edit the LDIF file (using find and replace) by adding "changetype: delete" to every record (
Now you can use your LDIF file to delete the records in AD.
Good luck!
bignewfAuthor Commented:
thanks for your help all. I will try all these solutions.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.