#25794 - 2002-07-25 12:29 AM
help required on this script
|
Peter Fry
Getting the hang of it
Registered: 2001-07-23
Posts: 95
Loc: Bristol UK
|
Hi
I've been asked to write a script that will allow non admin users to
1) Reset a Given Users Password 2) Unlock a Given Users Accounts
i've written a partial script that checks to see if user is allowed (reads a file) and then will run the commands i'm working out how to do SU for the net user command (not that hard) but i can't get the ADSI part to work as an admin user...... i'd rather not use ADSI as most of the machines that will be running this program will be normal NT4 machines and i don't really want to install the DCclient on them
I've not figured out how to unlock an account yet but that will probably be easy using ADSI is there any other way?
here is the code so far
code:
; Key User script V1.0 ; Created By PJF
;DEBUG ON
; Default Variables
$PASSWORD 123456
;MAIN SCRIPT
GOSUB AUTHORISEDUSER CLS ? "Key User Script V1.0" ? "Please Select from the following options" ? " " ? "1 : Reset Users Password" ? "2 : Unlock USers Account" ? "3 : Exit" ? " " ? "Please Enter 1, 2 or 3: " GET $OPTION
SELECT CASE $OPTION == "1" ; Reset Users Password GOSUB RESETPASSWORD EXIT
CASE $OPTION == "2" ; Unlock USers Account GOSUB UNLOCKACCOUNT EXIT
CASE $OPTION == "3" ; Exit ? "Press any Key to Exit" get $EXIT EXIT
CASE 1 ; default option ? "Please try again and select either 1, 2 or 3" EXIT
ENDSELECT
:AUTHORISEDUSER CLS
$file = "auth.txt" ;file with usernames If Open(1,"$file",2) <> 0 ? '"@serror" opening $file' ? " " ? "You must provide a list of existing users for this script to work." ? "Call the file auth.txt" ? " " Exit EndIF $NUL = Open(1,$file,2) ;this opens $file $KEYUSER = ReadLine(1) ;this read's in the first line of $FILE. AT(9,30) "Authorising User....." BOX(10,10,12,65,"single") $COL = 12 WHILE $COL < 64 AT(11,$COL) CHR(166) $COL = $COL + 1 $Y = 100 * ($COL - 12) / 52 IF ($COL & RND() ) = 0 ; simulate activiity SLEEP 1 ENDIF LOOP Do ;start loop IF @USERID = $KEYUSER $AUTHORISED = YES ENDIF $KEYUSER = ReadLine(1) ;this tells the script to get the next name in $FILE Until @error <> 0 ;the do..until will run, grabbing each name in $FILE until the end is reached. ;End Loop when end of $FILE is reached IF $AUTHORISED = "YES" AT(15,0) "User is Authorised" get $EXIT RETURN ENDIF AT(15,27) "USER IS NOT AUTHORISED" AT(16,27) "Press any Key to Exit" get $EXIT EXIT RETURN
:RESETPASSWORD
? " " ? "Please enter username: " GETS $USERNAME GOSUB BLANKPASSWORD Shell '%comspec% /c net user "$USERNAME" "$PASSWORD" /domain >nul' $A = GetObject("WinNT://sandh/$USERNAME,user") $A.put("PasswordExpired", 1) $A.setinfo ? "The Password for $USERNAME has been reset" GET $EXIT
RETURN
:UNLOCKACCOUNT
? " " ? "Please enter username: " GETS $USERNAME :BLANKUSERNAME IF $USERNAME = "" ? " " ? "USERNAME is Blank" ? " " EXIT ENDIF
RETURN
any help would be great, btw i'm sorry for the corney authorising user progress bar but i want the users to think something is actually happening......(so no flames please)
i also need to do some logging i.e. who runs the program and when and which users accounts they reset or unlock can anyone help with this?
Regards
Pete [ 24 July 2002, 12:50: Message edited by: Peter Fry ]
|
|
Top
|
|
|
|
#25796 - 2002-07-24 03:06 PM
Re: help required on this script
|
Peter Fry
Getting the hang of it
Registered: 2001-07-23
Posts: 95
Loc: Bristol UK
|
well i'm now making all the key users members of the account operator groups so i can get rid of the permissions problem (sneaky eh?)
i posted here because i didn't want a ADSI solution....... i just can't see anyother way of doing it atm
i can use net user to set a password i just can't get a command util that comes with NT to set the password expires flag - any ideas?
does net user $username /active:yes /domain clear the unlocked or just clear the deactived? flag?
i'm asking this because currently we are not using any password controls so i can't get the account lock out flag to be set to test........
if i can use net user i'd be very happy
my ideal solution is that i can use net user etc for evertyhing and not adsi so i don't have to install DCclients on my NT4 machines
thanks for the bump
Regards
Pete
|
|
Top
|
|
|
|
#25798 - 2002-07-24 03:18 PM
Re: help required on this script
|
Peter Fry
Getting the hang of it
Registered: 2001-07-23
Posts: 95
Loc: Bristol UK
|
you STAR thanks alot this saves me lots of time
|
|
Top
|
|
|
|
#25800 - 2002-07-24 03:35 PM
Re: help required on this script
|
Peter Fry
Getting the hang of it
Registered: 2001-07-23
Posts: 95
Loc: Bristol UK
|
yes but if you use
Shell '%comspec% /c net user "$USERNAME" "$PASSWORD" /domain >nul'
it sets the password but doesn't set the expiredflag so it doesn't ask the user to change it on next logon
|
|
Top
|
|
|
|
#25804 - 2002-07-24 04:15 PM
Re: help required on this script
|
Peter Fry
Getting the hang of it
Registered: 2001-07-23
Posts: 95
Loc: Bristol UK
|
Lonkero
it looks like a great program - one thing i need to be able to run it from workstations and not DCs the program recommends it is ran on DC and i can't seem to get your program to work when ran on my local machine.
i just can't believe there is nothing in standard in NT to set this flag
keep the help flowing tho it's all good
|
|
Top
|
|
|
|
#25808 - 2002-07-25 09:09 AM
Re: help required on this script
|
Peter Fry
Getting the hang of it
Registered: 2001-07-23
Posts: 95
Loc: Bristol UK
|
can i download it from the same place as before?
thanks for the help
|
|
Top
|
|
|
|
#25811 - 2002-07-26 11:41 AM
Re: help required on this script
|
Peter Fry
Getting the hang of it
Registered: 2001-07-23
Posts: 95
Loc: Bristol UK
|
thanks for all your help Lonkero, if you don't have time it's ok i'll find some other way of achieving this, i might have to go the adsi route
thanks again
Pete
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 756 anonymous users online.
|
|
|