VBS - User inkl. PW im AD automatisch aus einer CSV erstellen
Hallo,
ich brauche wiedereinmal eure Hilfe.
Es soll ein Skript erstellt werden, welches automatisch Benutzerobjekte aus einer Tabelle (CSV Datei) in einem AD unterhalb einer OU (hier "testou") erstellt.
Er zeigt mir in folgenden zeile einen Fehler an (rot markiert). Scheinbar kann er das Passwort nicht zuordnen.
Verbesserungsvorschläge begrüße ich, da ich noch ein Anfänger beim programmieren bin
Danke im vorraus
option explicit
dim objrootLDAP, objcontainer, objuser, objshell
dim fso, line, data, file, strou, strpw, strsam, strcn
set fso = createobject("scripting.filesystemobject")
set file = fso.opentextfile("user.csv", 1, false)
strou = "ou = testou ,"
Set objrootLDAP = getobject("LDAP:rootDSE")
Set objcontainer = getobject("LDAP:" & strou & objrootLDAP.Get("defaultnamingcontext"))
while not file.atendofstream
line = file.readline()
data = split(line,";")
strsam = data(0)
strcn = data(0)
strpw = data(1)
Set objUser = objContainer.Create("User", "cn=" & strcn)
objuser.sAMAccountName = strsam
objuser.SetPassword strpw
wend
file.close
dim objrootLDAP, objcontainer, objuser, objshell
dim fso, line, data, file, strou, strpw, strsam, strcn
set fso = createobject("scripting.filesystemobject")
set file = fso.opentextfile("user.csv", 1, false)
strou = "ou = testou ,"
Set objrootLDAP = getobject("LDAP:rootDSE")
Set objcontainer = getobject("LDAP:" & strou & objrootLDAP.Get("defaultnamingcontext"))
while not file.atendofstream
line = file.readline()
data = split(line,";")
strsam = data(0)
strcn = data(0)
strpw = data(1)
Set objUser = objContainer.Create("User", "cn=" & strcn)
objuser.sAMAccountName = strsam
objuser.SetPassword strpw
wend
file.close
Please also mark the comments that contributed to the solution of the article
Content-Key: 116916
Url: https://administrator.de/contentid/116916
Printed on: April 26, 2024 at 03:04 o'clock
2 Comments
Latest comment