Toon posts:

[win2k srv]meerdere gebruikersaccounts tegelijk aanmaken

Pagina: 1
Acties:
  • 121 views sinds 30-01-2008
  • Reageer

Verwijderd

Topicstarter
Hallo, momenteel gaan we over van windows NT4 naar windows 2000 advanced server en willen we een hele hoop gebruikers aanmaken (een school)
Deze gebruikers zijn nog niet aanwezig in windows NT4 server en zullen dus moeten worden aangemaakt.

Nu is mijn vraag of er een mogelijkheid is om ze allemaal tegelijk aan te maken. (bijvoorbeeld importeren uit een database of txt bestand)

Als deze er is zou dat een enorm hoop werk besparen.

grtz wimzzz :7

wlschell@hetnet.nl

  • elevator
  • Registratie: December 2001
  • Niet online

elevator

Officieel moto fan :)

je kan je users aan maken met "net user", maar mooier is met VBScript's je users aan te maken.

Kijk eens naar deze scripts, bv: http://www.microsoft.com/...scrguide/sas_usr_doig.asp

Verwijderd

Adsi gebruiken om users aan te maken roeleert, gaat retesnel is uit te lezen uit een text file.

Anders is er in de Resource Kit een tool die uit Excel (csv) kan importeren in Active Directory

Verwijderd

Topicstarter
thanx.... ik ga meteen aan de slag, ben alleen geen ster in vbscript, maar na wat oefenen lukt het hopelijk wel.

Verwijderd

Topicstarter
Het werkt!!!! _/-\o_

In het excel bestand staat in de eerste kolom (0) de ou, de tweede kolom (1) first name, derde kolom(2) last name, vierde kolom(3) email , vijfde kolom(4) de SAmaccount name (inlognaam) en de zesde kolom(5) het telefoon nummer.

In het script staat ook dat hij nieuwe ou's kan aanmaken, dit werkt niet maar ok dat is geen ramp. een paar ' ervoor en klaar is kees.

Alleen heb ik nog een vraag: in het script wordt het account standaard ge-enabled en gezegt dat de user bij de eerste login, zijn wachtwoord moet veranderen.
In onze situatie willen wij de leerlingen een wachtwoord toekennen, ook via het excel formulier. Alleen kan ik niet achter de variabele komen om dit te doen.

u.Put " ???? ", oXL.activecell.offset(0, 6).Value 'wachtwoord

Iemand enig idee wat er bij de ???? moet staan? of een andere manier om dit te doen?

bij voorbaat dank,

wimzzz :z


' Windows Script Host Sample Script
'
' ------------------------------------------------------------------------
' Copyright (C) 1996 Microsoft Corporation
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Microsoft has no warranty,
' obligations or liability for any Sample Application Files.
' ------------------------------------------------------------------------
'
'This script is adds users from the Windows NT DS
'via ADSI. The script reads an EXCEL spreadsheet that contains a page
'of users to add.
'
'The sample uses the directory root "LDAP://DC=ArcadiaBay,DC=Com,O=Internet"
'Change the directory path in the EXCEL spreadsheet to match your DS
'before running this sample.
'
'
'
'To add users, run ADDUSERS.VBS with %windir%\"Your Samples Directory
Here"\AddUsers.XLS.
'To Delete users, run DELUSERS.VBS with %windir%\"Your Samples Directory
Here"\DelUsers.XLS.


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/delete
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("Add").Activate

'Put the cursor in the starting cell and read the DS root
oXL.ActiveSheet.range("A2").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 = oXL.activecell.Value

'Step to the next row
oXL.activecell.offset(1, 0).Activate

'Until we run out of rows
Do While oXL.activecell.Value <> ""

'if the requested OU is a new one...
If oXL.activecell.Value <> ou Then
'Pick up the OU name...
ou = oXL.activecell.Value

'Compose the ADSI path...
s = "LDAP://" + ou+"," + root

'Show it to the user...
WScript.Echo s

'And get the object
Set c = GetObject(s)
End If

'Compose the user common name name from first and last names...
uname = "CN=" + oXL.activecell.offset(0, 1).Value + " " + oXL.activecell.offset(0, 2).Value

'Create the new user object...
Set u = c.Create("user", uname)

'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 "mail", oXL.activecell.offset(0, 3).Value 'Email
u.Put "sAMAccountName", oXL.activecell.offset(0, 4).Value 'Sam Acct
u.Put "telephoneNumber", oXL.activecell.offset(0, 5).Value 'Phone

'Enable the account, must change pw @ logon
u.Put "userAccountControl",16

'...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