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
Alles anzeigen
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
- Dim oXL
- Dim u
- Dim c
- Dim root
- Dim ou
- Dim TextXL
- Dim CRLF
- Dim oArgs
- 'Get the command line args
- set oArgs=wscript.arguments
- CRLF = Chr(13) & Chr(10)
- 'If no command line arguments provided, prompt for file containing users to add
- If oArgs.Count = 0 Then
- TextXL = InputBox("This scripts reads an Excel spreadsheet and adds" & _
- "users from the Windows NT DS via ADSI." & CRLF & CRLF & _
- "Before starting, change the DS root in the EXCEL spreadsheet to match " & _
- "your DS." & CRLF & CRLF & _
- "Type in the path of a file containing users to add or delete" & CRLF & CRLF & _
- "Sample Add User file: ADDUSERS.XLS" & CRLF & _
- "Sample Delete User file: DELUSERS.XLS" & CRLF)
- 'Else file containing users is the first argument
- Else
- TextXL = oArgs.item(0)
- End If
- If TextXL = "" Then
- WScript.Echo "No input file provided. Stopping the script now."
- WScript.Quit(1)
- End If
- 'We will use ou to control loop, so set initial value to null
- ou = ""
- 'Start EXCEL and display it to the user
- Set oXL = WScript.CreateObject("EXCEL.application")
- oXL.Visible = True
- 'Open the workbook passed in the command line
- oXL.workbooks.open TextXL
- 'Activate the Add page
- ' oXL.sheets("Del").Activate
- 'Put the cursor in the starting cell and read the DS root
- oXL.ActiveSheet.range("A1").Activate ' this cell has the DS root in it
- 'Show it to the user
- WScript.Echo oXL.activecell.Value
- 'This is the starting point in the ds
- root = "DC=XYZ,DC=XYZ,DC=de"
- 'Step to the next row
- oXL.activecell.offset(1, 0).Activate
- 'Until we run out of rows
- Do While oXL.activecell.Value <> ""
- ou = "ou=NewUsers"
- 'Compose the ADSI path...
- s = "LDAP://" + ou+"," + root
- WScript.Echo s
- 'And get the object
- Set c = GetObject(s)
- 'Compose the user common name name from first and last names...
- uname = "CN=" + oXL.activecell.offset(0, 2).Value + "\, " + oXL.activecell.offset(0, 1).Value
- 'Create the new user object...
- Set u = c.Create("user", uname)
- uname =oXL.activecell.offset(0, 2).Value + ", " + oXL.activecell.offset(0, 1).Value
- 'Set the properties of the new user
- u.Put "givenName", oXL.activecell.offset(0, 1).Value 'givenName
- u.Put "sn", oXL.activecell.offset(0, 2).Value 'sn
- u.Put "displayName", uname 'Displayname
- u.Put "sAMAccountName", oXL.activecell.offset(0, 4).Value 'Sam Acct
- If oXL.activecell.offset(0, 7).Value <> "" Then
- If oXL.activecell.offset(0, 7).Value = "Tutor" Then
- u.Put "description", "XYZ"
- u.Put "department", "XYZ"
- End If
- Else
- u.Put "description", "XYZ"
- u.Put "department", "XYZ"
- End If
- u.Put "profilePath", "\\XYZ\profiles\" + oXL.activecell.offset(0, 4).Value
- u.Put "homeDirectory", "\\XYZ\users\" + oXL.activecell.offset(0, 4).Value
- u.Put "homeDrive", "T" 'homeDrive
- u.Put "scriptPath", "drucker.bat" 'script
- u.Put "streetAddress", "XYZ" 'Strasse
- u.Put "postalCode", "XYZ"
- u.Put "st", "XYZ"
- u.Put "l", "XYZ"
- '...and update the DS
- u.SetInfo
- 'Done with this object, discard it
- Set u = Nothing
- 'Step to the next user...
- oXL.activecell.offset(1, 0).Activate 'Next row
- Loop
- 'Done. close excel spreadsheet
- oXL.application.quit