Page 1 of 1 1
Topic Options
#57622 - 2001-07-25 05:04 AM account lockout & cusrmgr
Anonymous
Unregistered


i've written an administrative kixtart script that does some common task a field technician may need. Everything works EXCEPT resetting the account lockout parameter (which gets set after a user logs in with the wrong password too many times).

Can anyone tell me why cusrmgr
run "cusrmgr -u "+chr(34)+$username+chr(34)+" -s AccountLockout -m \\aisd-fr" does not work (see code below for exact syntax). No error message are given and all the other command work great. Is there another way to accomplish this without cusrmgr or net use? I don't want to use net use because non-administators are using this. Also, I know in this case it is not a rights issue because I am running the script as a domain admin.

Thanks

:begin
break on
$username = ""
$password = ""
$choice = ""
$command = ""
$message = ""
$OS = ""
$campus = ""
$directory = ""
$qusername = ""
$q = chr(34)

cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "Account Menu"
color w+/b
Box (3,0,30,50,double)
AT (5,2) "1. Change Password & Remove Password Lockout"
AT (7,2) "2. Remove Password Lockout"
AT (9,2) "3. Enable Password Lockout"
AT (11,2) "4. Enable Account (Network Admins only)"
AT (13,2) "5. Disable Account (Network Admins only)"
AT (15,2) "6. Get PC Info"
AT (17,2) "7. Get PC Bios Info"
AT (19,2) "Q. Quit"
AT (25,2) "Enter Selection (1-7, Q) ?" get $choice

Select
case $choice = "1"
goto "chngpw"
case $choice = "2"
goto "rmlock"
case $choice = "3"
goto "enlock"
case $choice = "4"
goto "enacct"
case $choice = "5"
goto "dsacct"
case $choice = "6"
goto "compinfo"
case $choice = "7"
goto "biosinfo"
case $choice = ""
goto "end"
case $choice =" "
goto "end"
case $choice = "q"
goto "end"
endselect

:chngpw
cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "Change Password & Remove Password Lockout"
color w+/b
Box (3,0,30,50,double)

AT (5,2) "Enter UserID: " gets $username
AT (7,2) "Enter Password: " gets $password
if $username = "" or $username = " "
color r+/b
At (29,2) "No UserID provided. Try again..."
sleep 3
goto "begin"
endif
if $password = "" or $password = " "
color r+/b
At (29,2) "No password provided. Try Again..."
sleep 3
goto "begin"
endif
$command = "cusrmgr -u "+chr(34)+$username+chr(34)+" -P "+$password+" -m \\aisd-fr"
run "$command"
sleep 2
$command = "cusrmgr -u "+chr(34)+$username+chr(34)+" +s MustChangePassword -m \\aisd-fr"
run "$command"
sleep 2
$command = "cusrmgr -u "+chr(34)+$username+chr(34)+" -s AccountLockout -m \\aisd-fr"
run "$command"
sleep 2
AT (25,2) "Press any key to return to main menu..." get $choice
goto "begin"

:rmlock
cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "Remove Password Lockout"
color w+/b
Box (3,0,30,50,double)
AT (5,2) "Enter UserID: " gets $username
if $username = "" or $username = " "
color r+/b
At (29,2) "No UserID provided. Try again..."
sleep 3
goto "Begin"
endif
$command = "cusrmgr -u "+chr(34)+$username+chr(34)+" -s AccountLockout -m \\aisd-fr"
run "$command"
AT (25,2) "Press any key to return to main menu..." get $choice
goto "begin"

:enlock
cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "Enable Password Lockout"
color w+/b
Box (3,0,30,50,double)
AT (5,2) "Enter UserID: " gets $username
if $username = "" or $username = " "
color r+/b
At (29,2) "No UserID provided. Try again..."
sleep 3
goto "Begin"
endif
$command = "cusrmgr -u "+chr(34)+$username+chr(34)+" +s AccountLockout -m \\aisd-fr"
run "$command"
AT (25,2) "Press any key to return to main menu..." get $choice
goto "begin"

:enacct
cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "Enable Account"
color w+/b
Box (3,0,30,50,double)
AT (5,2) "Enter UserID: " gets $username
if $username = "" or $username = " "
color r+/b
At (29,2) "No UserID provided. Try again..."
sleep 3
goto "Begin"
endif
$command = "cusrmgr -u "+chr(34)+$username+chr(34)+" -s AccountDisabled -m \\aisd-fr"
run "$command"
AT (25,2) "Press any key to return to main menu..." get $choice
goto "begin"

:dsacct
cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "Disable Account"
color w+/b
Box (3,0,30,50,double)
AT (5,2) "Enter UserID: " gets $username
if $username = "" or $username = " "
color r+/b
At (29,2) "No UserID provided. Try again..."
sleep 3
goto "Begin"
endif
$command = "cusrmgr -u "+chr(34)+$username+chr(34)+" +s AccountDisabled -m \\aisd-fr"
run "$command"
AT (25,2) "Press any key to return to main menu..." get $choice
goto "begin"

:sndmsg
cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "Send Message"
color w+/b
Box (3,0,30,50,double)
AT (5,2) "Enter UserID or Computer Name: " gets $username
if $username = "" or $username = " "
color r+/b
At (29,2) "No UserID provided. Try again..."
sleep 3
goto "Begin"
endif
AT (7,2) "Enter Message: " gets $message
$command = "sendmessage("+$username +","+$message+")"
run "$command"
goto "begin"

:compinfo
if @INWIN = 1
$OS = "NT or W2K"
endif
if @inwin = 2
$OS = "9x"
endif
cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "Computer Informaton"
color w+/b
Box (3,0,30,50,double)
AT (5,2) "Date: " @DATE " Time: " @TIME
AT (6,2) "NIC Address: " @ADDRESS
AT (7,2) "IP Address: " @IPADDRESS0
AT (8,2) "Workstation Name: "@WKSTA
AT (9,2) "Host Name: " @HOSTNAME
AT (10,2) "PC Domain: " @DOMAIN
AT (11,2) "OS: " $OS
AT (12,2) "NT Version: " @DOS
AT (13,2) "Network Software Directory: " @LANROOT
AT (14,2) "Network Software Version: " @LM
AT (25,2) "Press any key to return to main menu..." get $choice
goto "begin"

:biosinfo
cls
color b/w+
Box (0,0,2,50, double)
AT (1,2) "PC Bios Informaton"
AT (3,2) "PC BIOS Version: " run "cscript checkbios.vbs"
sleep 5
AT (50,2) "Press any key to return to main menu..." get $choice
goto "begin"

:end


Top
#57623 - 2001-07-25 08:07 AM Re: account lockout & cusrmgr
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I don't quite follow you. You don't want to use net use 'cause others than admins are using the script?
you don't have care about that. Then it is rights issue (as non admins shouldn't and can't use it).
I don't follow you in the name of the command either, net use? I think you mean user.
in net user there no such thing as removing the lock. there is only disable/enable switch.
and then, when user is logging on with wrong pass, the account will be locked approx. fo 15mins.
and I think that's good for the user to think that he/she shouldn't huzzle so much.
about changing values, in nt-environment there is no way without 3rd party tool and w2k to change the values, some com-automation could be used.
well, others might have some more info on that and other stuff, I don't

anyway, cheers,

_________________________
!

download KiXnet

Top
#57624 - 2001-07-25 04:07 PM Re: account lockout & cusrmgr
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
galdiano

cusrmgr.exe sets the value of KiXtart's @ERROR macro, try changing your line from this...

$command = "cusrmgr -u "+chr(34)+$username+chr(34)+" -s AccountLockout -m \\aisd-fr"

to this ...

$command = '%comspec% /c cusrmgr -u "$username" -s AccountLockout -m \\aisd-fr'

[this gets rid of those chr(34)'s as well]

then change your RUN "$COMMAND" to SHELL "$COMMAND"

[this is probably better anyway, SHELL pauses the script until the command terminates - a good thing?]

and put this right after it ...

?"ERROR @ERROR : @SERROR"

and re-run. Does cusrmgr.exe report anything unusual ?

-Shawn

[ 25 July 2001: Message edited by: Shawn ]

Top
#57625 - 2001-07-25 04:33 PM Re: account lockout & cusrmgr
Anonymous
Unregistered


Shawn,

I made the changes you suggested and I get the same results. The error code returned was 0 and it said the operation was completed successfully. I also get the same results if I run cusrmgr from the command line. However, under the account properties, the Account is Locked out remains checked.

I'm stumped...

Top
#57626 - 2001-07-25 04:55 PM Re: account lockout & cusrmgr
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
is \\aisd-fr your PDC ? If not, try it against your PDC.
Top
#57627 - 2001-07-25 06:27 PM Re: account lockout & cusrmgr
Anonymous
Unregistered


yes, aisd-fr is the PDC. While I would like to figure out why cusrmgr is not working, I have found a work around. joeware.net provides a freeware utility called unlock.exe which resets the account lockout parameter quickly and easily.

I'm would still like to figure out how to set the lockout parameter (set the password lockout instead of clearing it), but that is just gravy.

Thanks!

Top
#57628 - 2001-07-25 06:46 PM Re: account lockout & cusrmgr
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
My testing with cusrmgr.exe is yeilding un-predictable results. Run it once - it works - run it again - it doesn't work - go into usrmgr and poke around a bit then run cusrmgr again - and it works - can't get a handle on the problem.

Glad you found a work-around. Well - on Windows 2000 - with suitable credentials - you can set/clear just about anything you want with ADSI. Let us know if you want more info...

-Shawn

Top
#57629 - 2001-07-27 01:52 PM Re: account lockout & cusrmgr
Anonymous
Unregistered


Galdiano,

Since we have to help users outside '9-to-5' hours we found it very usefull to be able to reset the account lockout param
We use ntuser.exe, works like a charm.

Hope this helps!

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 879 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.128 seconds in which 0.099 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org