"primoz88" <> wrote in message
news

...
>
> Hello Everyone,
>
> I have searched the forum ho to disable users' accounts in AD, but
> without success. I have an Excel file with one value set in column (Pre
> W2K Name). I would like to create the script to mass disable users'
> accounts in AD.
>
> Can you please help me out?
>
> Thanks a million
>
>
> --
> primoz88
> ------------------------------------------------------------------------
> primoz88's Profile: http://forums.techarena.in/members/143937.htm
> View this thread: http://forums.techarena.in/server-scripting/1260301.htm
>
> http://forums.techarena.in
>
A VBScript program would need to read the pre-Windows 2000 names from the
spreadsheet, use the NameTranslate object to convert to the Distinguished
Name, bind to each user object, then set the appropriate bit of the
userAccountControl attribute to disable the account (or use the
AccountDisabled property method of the user object). You can use an example
VBScript program on my web site to modify users in bulk from a spreadsheet
linked here:
http://www.rlmueller.net/UpdateUsers.htm
Since userAccountControl is not a single-valued string attribute, you must
use the program UpdateUsers2.vbs (download UpdateUsers2.txt and rename to
*.vbs). The first row of the spreadsheet must have the attribute names. Your
first column with pre-Windows 2000 names should have the header
"sAMAccountName". Add a second column with the heading "userAccountControl".
The value in the second column for each user to be disabled should be
"ADS_UF_ACCOUNTDISABLE". The program will read each row of the spreadsheet,
convert the sAMAccountName into the Distinguished Name, bind to the user
object, and set the appropriate bit of the userAccountControl attribute to
disable the account. The program assumes all users are in the domain you
authenticated to. The spreadsheet UpdateUsers4.xls linked on the page is an
example, except you only need two columns, the one headed "sAMAccountName"
and one headed "userAccountControl". The program writes a log to document
what happened. The name and path of the log file and the spreadsheet are
both hardcoded in the program, so you should modify these for your needs. I
hope this helps.
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--