Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. '*******************
  2. '* Script by Alex
  3. '* Question 2
  4. '*******************
  5.  
  6. On Error Resume Next
  7.  
  8. strDestination = "cn=Users,dc=contoso,dc=com"
  9. set objDestination = GetObject("LDAP://" & strDestination)
  10.  
  11. '* Open the file for reading.
  12. Const ForReading = 1
  13. Set objFSO = CreateObject("Scripting.FileSystemObject")
  14. Set objTextFile = objFSO.OpenTextFile _
  15. ("c:\Users\Administrator\Desktop\stufftoadd.txt", ForReading)
  16.  
  17. '* First two lines are junk, read and discard
  18. strJunk = objTextFile.ReadLine
  19. Wscript.echo("Assuming CSV in format: " & strJunk)
  20. strJunk = objTextFile.ReadLine
  21.  
  22. '* Read the rest of the lines and parse
  23. '* Each line will have two things: user CN, and their password.
  24. Do Until objTextFile.AtEndOfStream
  25. strNextLine = objTextFile.ReadLine
  26. arrToAdd= Split(strNextLine, ",")
  27. set objUser = objDestination.Create("user", "cn=" & arrToAdd(0))
  28. objUser.sAMAccountName = arrToAdd(0)
  29. objUser.SetPasword arrToAdd(1)
  30. objUser.AccountDisabled = False
  31. objUser.setInfo
  32. Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement