• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1059
  • Last Modified:

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?
0
bignewf
Asked:
bignewf
  • 2
3 Solutions
 
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
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now