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
bignewfAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joseph DalyCommented:
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

0
Joseph DalyCommented:
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.
user1
user2
user3
user4

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
minvisCommented:
Use "CSV to LDIF converter" (http://www.novell.com/coolsolutions/tools/14462.html)
Then edit the LDIF file (using find and replace) by adding "changetype: delete" to every record (http://www.computerperformance.co.uk/Logon/Logon_LDIF.htm#LDIFDE%20Delete)
Now you can use your LDIF file to delete the records in AD.
Good luck!
0
bignewfAuthor Commented:
thanks for your help all. I will try all these solutions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.