problem with script for new user creation in AD

Joined
Aug 10, 2001
Messages
2,312
i have a script that i would like to read values out of an excel file, and then use them to create several users in windows 2000 AD. the problem i think i have is that i have a password policy requiring complex passwords (IOW- can't be blank). i believe i can use the SetPassword method to set the password, but here's the rub. you seem to need an existing object to use it on. but i can't create the object without it having a complex password. therefore i can never get to use the setpassword method to set the password to something complex.

anyone have any ideas around this without altering the domain policy or creating these things manually?

Code:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
    ("C:\mailboxes.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
    Set objOU = GetObject("LDAP://ou=Mailboxes,dc=domain,dc=org")
    Set objUser = objOU.Create _
       ("User", "cn=" & objExcel.Cells(intRow, 1).Value)
        objUser.displayName = objExcel.Cells(intRow, 2).Value
        objUser.sAMAccountName = objExcel.Cells(intRow, 3).Value
        objUser.GivenName = objExcel.Cells(intRow, 4).Value
        objUser.SN = objExcel.Cells(intRow, 5).Value
        objOU.mail = objExcel.Cells(intRow, 6).Value
        objUser.description = "This account has been created by a script."
        objUser.SetPassword "p@ssw0rd"
        objUser.accountDisabled = FALSE
        objUser.CreateMailbox
        objOU.SetInfo

    intRow = intRow + 1
Loop
objExcel.Quit
 
Back
Top