W2k3 - User mittels VB-Script aus Excel Tabelle erstellen

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • W2k3 - User mittels VB-Script aus Excel Tabelle erstellen

    Hallo,

    Ich versuche mich das erste Mal an der Accounterstellung mittels VB-Script.
    Das Script ist eine Vorlage gewesen, welche ich nur versucht habe meinen Bedürfnissen anzupassen.
    Nun habe ich ein paar Fragen:

    1. Wie hinterlege ich für jeden User ein eigenes Passwort aus der Excel Tabelle (min. 7 Zeichen)?
    2. Wie definiere ich die Gültigkeit des Kontos (1 Jahr ab Erstellung)?
    3. Wie weise ich dem User zusätzlich eine Gruppe zu?
    4. Wie aktiviere ich die Konten bei der Erstellung?
    5. Wie weise ich als Land Deutschland zu?

    Danke für die Mühe

    PS: Hier noch mal das Script

    Quellcode

    1. Dim oXL
    2. Dim u
    3. Dim c
    4. Dim root
    5. Dim ou
    6. Dim TextXL
    7. Dim CRLF
    8. Dim oArgs
    9. 'Get the command line args
    10. set oArgs=wscript.arguments
    11. CRLF = Chr(13) & Chr(10)
    12. 'If no command line arguments provided, prompt for file containing users to add
    13. If oArgs.Count = 0 Then
    14. TextXL = InputBox("This scripts reads an Excel spreadsheet and adds" & _
    15. "users from the Windows NT DS via ADSI." & CRLF & CRLF & _
    16. "Before starting, change the DS root in the EXCEL spreadsheet to match " & _
    17. "your DS." & CRLF & CRLF & _
    18. "Type in the path of a file containing users to add or delete" & CRLF & CRLF & _
    19. "Sample Add User file: ADDUSERS.XLS" & CRLF & _
    20. "Sample Delete User file: DELUSERS.XLS" & CRLF)
    21. 'Else file containing users is the first argument
    22. Else
    23. TextXL = oArgs.item(0)
    24. End If
    25. If TextXL = "" Then
    26. WScript.Echo "No input file provided. Stopping the script now."
    27. WScript.Quit(1)
    28. End If
    29. 'We will use ou to control loop, so set initial value to null
    30. ou = ""
    31. 'Start EXCEL and display it to the user
    32. Set oXL = WScript.CreateObject("EXCEL.application")
    33. oXL.Visible = True
    34. 'Open the workbook passed in the command line
    35. oXL.workbooks.open TextXL
    36. 'Activate the Add page
    37. ' oXL.sheets("Del").Activate
    38. 'Put the cursor in the starting cell and read the DS root
    39. oXL.ActiveSheet.range("A1").Activate ' this cell has the DS root in it
    40. 'Show it to the user
    41. WScript.Echo oXL.activecell.Value
    42. 'This is the starting point in the ds
    43. root = "DC=XYZ,DC=XYZ,DC=de"
    44. 'Step to the next row
    45. oXL.activecell.offset(1, 0).Activate
    46. 'Until we run out of rows
    47. Do While oXL.activecell.Value <> ""
    48. ou = "ou=NewUsers"
    49. 'Compose the ADSI path...
    50. s = "LDAP://" + ou+"," + root
    51. WScript.Echo s
    52. 'And get the object
    53. Set c = GetObject(s)
    54. 'Compose the user common name name from first and last names...
    55. uname = "CN=" + oXL.activecell.offset(0, 2).Value + "\, " + oXL.activecell.offset(0, 1).Value
    56. 'Create the new user object...
    57. Set u = c.Create("user", uname)
    58. uname =oXL.activecell.offset(0, 2).Value + ", " + oXL.activecell.offset(0, 1).Value
    59. 'Set the properties of the new user
    60. u.Put "givenName", oXL.activecell.offset(0, 1).Value 'givenName
    61. u.Put "sn", oXL.activecell.offset(0, 2).Value 'sn
    62. u.Put "displayName", uname 'Displayname
    63. u.Put "sAMAccountName", oXL.activecell.offset(0, 4).Value 'Sam Acct
    64. If oXL.activecell.offset(0, 7).Value <> "" Then
    65. If oXL.activecell.offset(0, 7).Value = "Tutor" Then
    66. u.Put "description", "XYZ"
    67. u.Put "department", "XYZ"
    68. End If
    69. Else
    70. u.Put "description", "XYZ"
    71. u.Put "department", "XYZ"
    72. End If
    73. u.Put "profilePath", "\\XYZ\profiles\" + oXL.activecell.offset(0, 4).Value
    74. u.Put "homeDirectory", "\\XYZ\users\" + oXL.activecell.offset(0, 4).Value
    75. u.Put "homeDrive", "T" 'homeDrive
    76. u.Put "scriptPath", "drucker.bat" 'script
    77. u.Put "streetAddress", "XYZ" 'Strasse
    78. u.Put "postalCode", "XYZ"
    79. u.Put "st", "XYZ"
    80. u.Put "l", "XYZ"
    81. '...and update the DS
    82. u.SetInfo
    83. 'Done with this object, discard it
    84. Set u = Nothing
    85. 'Step to the next user...
    86. oXL.activecell.offset(1, 0).Activate 'Next row
    87. Loop
    88. 'Done. close excel spreadsheet
    89. oXL.application.quit
    Alles anzeigen