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

Posted on 2008-11-05
Last Modified: 2012-05-05
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?
Question by:bignewf
    LVL 35

    Assisted Solution

    by:Joseph Daly
    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

    LVL 35

    Accepted Solution

    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

    LVL 5

    Assisted Solution

    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!
    LVL 15

    Author Closing Comment

    thanks for your help all. I will try all these solutions.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Companies that have implemented Microsoft’s Active Directory need to ensure that the Active Directory is configured and operating properly. If there are issues found and not resolved, it eventually leads the components to fail or stop working and fi…
    Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
    This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now