remcovanuitert
Technical User
I work for a school, we have about 700 users in Active Directory (Win2003). I need to reset the passwords for all students and teachers to a random password.
I created the users last year using the script below (which I created by merging some scripts I found on the internet). The script reads the information from an excel sheet and creates the users. The password column contained a random combination of letters and numbers.
It seems I will have to change this line (from the script below):
Set oUser = ou.Create("user","CN=" & login)
to something like:
Set oUser = ou.FindUser("user","CN=" & login) ?
to be able to change the password.
To make a long story short, what method can I use to get a user object in order to modify it?
Thanks in advance,
Remco
**** SCRIPT *****
set x = getobject(,"excel.application")
set ou = GetObject("LDAP://OU=GuestAccounts,DC=DOMAINNAME,DC=NET")
r = 1
Const ou_name = "Users"
do until len(x.cells(r, 1).value) = 0
login = x.cells(r, 1).value
firstname = x.cells(r, 2).value
lastname = x.cells(r, 3).value
password = x.cells(r, 4).value
fullname = firstname & " " & lastname
Set oUser = ou.Create("user","CN=" & login)
oUser.Put "userPrincipalname", fullname & "@esmol.net"
oUser.Put "samAccountName", login
oUser.Put "givenName", firstname
oUser.Put "sn", lastname
oUser.Put "displayName", fullname
oUser.SetInfo
oUser.SetPassword password
oUser.SetInfo
oUser.AccountDisabled = False
oUser.SetInfo
r = r + 1
set objOU = Nothing
set oUser = Nothing
Loop
set x = nothing
set ou = nothing
set r = nothing
I created the users last year using the script below (which I created by merging some scripts I found on the internet). The script reads the information from an excel sheet and creates the users. The password column contained a random combination of letters and numbers.
It seems I will have to change this line (from the script below):
Set oUser = ou.Create("user","CN=" & login)
to something like:
Set oUser = ou.FindUser("user","CN=" & login) ?
to be able to change the password.
To make a long story short, what method can I use to get a user object in order to modify it?
Thanks in advance,
Remco
**** SCRIPT *****
set x = getobject(,"excel.application")
set ou = GetObject("LDAP://OU=GuestAccounts,DC=DOMAINNAME,DC=NET")
r = 1
Const ou_name = "Users"
do until len(x.cells(r, 1).value) = 0
login = x.cells(r, 1).value
firstname = x.cells(r, 2).value
lastname = x.cells(r, 3).value
password = x.cells(r, 4).value
fullname = firstname & " " & lastname
Set oUser = ou.Create("user","CN=" & login)
oUser.Put "userPrincipalname", fullname & "@esmol.net"
oUser.Put "samAccountName", login
oUser.Put "givenName", firstname
oUser.Put "sn", lastname
oUser.Put "displayName", fullname
oUser.SetInfo
oUser.SetPassword password
oUser.SetInfo
oUser.AccountDisabled = False
oUser.SetInfo
r = r + 1
set objOU = Nothing
set oUser = Nothing
Loop
set x = nothing
set ou = nothing
set r = nothing