Does the following code look okay? Want to see if anyone can spot any mistakes I may have made. This will be pulling from a pre-formatted Excel document - I have already specified all needed Cell locations.
Things I want clarified:
How many times can you invoke SetInfo and did I use it more than needed? I was under the impression that a SetInfo would be needed before a SetPassword can be used, but I could be very wrong.
Does this line look okay? Was I correct to separate multiple cells using a comma in order to put all the info together? I know it worked with an Echo command:
Set objUser = objOU.Create _ ("User", "cn=" & objExcel.Cells(intRow, 3).Value, objExcel.Cells(intRow, 2).Value, objExcel.Cells(intRow, 19).Value)
Is this the correct code for setting a password to never expire?
objUser.Put "userAccountControl", intUAC XOR _ ADS_UF_DONT_EXPIRE_PASSWD
Full code below, I'd appreciate any feedback on anything else that is found.
Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open _ ("C:\Book1.xls") intRow = 2 Do Until objExcel.Cells(intRow,1).Value = "" Set objOU = GetObject _ ("ou=" & objExcel.Cells(intRow, 13).Value & _ ", dc=satdc, dc=com") Set objUser = objOU.Create _ ("User", "cn=" & objExcel.Cells(intRow, 3).Value, objExcel.Cells(intRow, 2).Value, objExcel.Cells(intRow, 19).Value) objUser.sAMAccountName = objExcel.Cells(intRow, 19).Value & ".sat" objUser.GivenName = objExcel.Cells(intRow, 3).Value objUser.SN = objExcel.Cells(intRow, 2).Value objUser.SetInfo objUser.AccountDisabled = False objUser.AccountExpirationDate = Date + 365 objUser.SetPassword objExcel.Cells(intRow, 9).Value objUser.SetInfo objUser.Put "userAccountControl", intUAC XOR _ ADS_UF_DONT_EXPIRE_PASSWD objUser.HomeDirectory = "\\satdc" & "\" & "Users" & "\" & _ objUser.Get("sAMAccountName") objUser.homeDrive = "U:" objUser.SetInfo intRow = intRow + 1 Loop objExcel.Quit