Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 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 objectFSO = CreateObject("Scripting.FileSystemObject")
  14. Set objectTextFile = 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. strJunk = objTextFile.ReadLine
  20.  
  21. '* Read the rest of the lines and parse
  22. '* Each line will have two things: user CN, and their password.
  23. Do Until objTextFile.AtEndOfStream
  24. strNextLine = objTextFile.ReadLine
  25. arrToAdd= Split(strNextLine, ",")
  26. set objUser = objDestination.Create("user", "cn=" & arrToAdd(0))
  27. objUser.sAMAccountName = arrToAdd(0)
  28. objUser.SetPasword arrToAdd(1)
  29. objUser.AccountDisabled = False
  30. objUser.setInfo
  31. Next
  32. Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement