Sign in to follow this  
Followers 0
erifash

RunAsSet

11 posts in this topic

#1 ·  Posted (edited)

My latest project requires a username and password validation function for any computer on the network. It works fine for "normal" logins, except it chokes on blank passwords. Apparantly RunAsSet doesn't handle accounts that don't have a password. :P Is there some way of getting around this? Another user in this topic was having the same problem, but no one answered his question. I really don't want to have to resort to changing the user's password.

Here is the code I have:

Opt("RunErrorsFatal", 0)

Func _ValidUserPass( $computer, $username, $password )
    Local $valid = True
    RunAsSet($username, $computer, $password, 0)
    Run(@ComSpec & " /c  echo test", @SystemDir, @SW_HIDE)
    If @error Then $valid = False
    RunAsSet()
    Return $valid
EndFunc

$comp = InputBox("Computer", "Please type in the computer name:", @ComputerName)
$user = InputBox("Username", "Please type in the username:", @UserName)
$pass = InputBox("Password", "Please type in the password:", "", "")
MsgBox(0, "Valid User?", _ValidUserPass($comp, $user, $pass))
It will return False if you supply a blank password.

Thank you for your time and I hope we can get this fixed! :lmao:

Edited by erifash

Share this post


Link to post
Share on other sites



Does the network use a Domain? Or workgroup?

_ Steven

Share this post


Link to post
Share on other sites

This is for a remote command on a different computer (ie. on a network) as the script? Or same computer the script is run?

- Steven

Either. If the user specifies a username and password then it needs to check if the credentials are valid. The user can select any computer on the network -- including the computer they're using.

Share this post


Link to post
Share on other sites

Yeah, I was just reading the help file and saw that for RunAsSet the second parameter is specified as the "domain" not the "computer name" so I wonder if that makes a difference. In either case, can you ever run a windows command on a remote computer without a password? I'm afraid I've never worked on a network that insecure and I'm not on a network right now to test... but I would have thought you'd have to have a password to get any control whatsoever to the remote computer.

- Steven

Share this post


Link to post
Share on other sites

Yeah, I was just reading the help file and saw that for RunAsSet the second parameter is specified as the "domain" not the "computer name" so I wonder if that makes a difference. In either case, can you ever run a windows command on a remote computer without a password? I'm afraid I've never worked on a network that insecure and I'm not on a network right now to test... but I would have thought you'd have to have a password to get any control whatsoever to the remote computer.

- Steven

The domain can be swapped for the computer name. I'm just trying to cover all possible outcomes because this program will be used in a home and buisness environment. :P

Share this post


Link to post
Share on other sites

RunAsSet uses the Windows Secondary Logon service (RunAs Service in Win2k?) and so would have the same restrictions about blank passwords, e.g. by default you can't right-click and Run As a program using credentials with a blank password. I think that there may be Group Policies that remove this restriction, but I don't know precisely which and have no experience with using them...


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

does it help that you can use the net user command to change the password?

You can ask the user for the password and if they've supplied a blank one you can set the username to some arbitrary one for the duration of the command and set it back to blank when you are finished.

Of course, you have to be careful that they really don't have a password because if they accidentally submit a blank you've just shredded their password! lol

Also, this will ONLY work for administrator accounts... limited accounts can't set their passwords with the net user command.

net user MyUserName MyPassword

- Steven

Edited by s_mack

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

does it help that you can use the net user command to change the password?

You can ask the user for the password and if they've supplied a blank one you can set the username to some arbitrary one for the duration of the command and set it back to blank when you are finished.

Of course, you have to be careful that they really don't have a password because if they accidentally submit a blank you've just shredded their password! lol

Also, this will ONLY work for administrator accounts... limited accounts can't set their passwords with the net user command.

net user MyUserName MyPassword

- Steven

Yeah, I saw that way... I don't want to use it for two reasons:

1. *shredding password*

2. The user might not be an administrator

I really wish there was some way to accomplish this, it's getting really annoying. :P

@DaveF: Thank you for that information!

Edited by erifash

Share this post


Link to post
Share on other sites

Well... for shredding passwords you can do some anciliarry checks to make sure the password is, in fact, blank (and then you wouldn't be shredding anything).

And if they aren't administrators... then can they run remote programs in XP? I didn't think so.

So the users that can't do it anyway don't have to worry about it because they are only doing local jobs (correct me if I'm wrong) and the ones that can do it just need a password.

Really, it seems to me then that your only worry is the local non-administrator user running a local command... at that point you don't need the RunAsSet then, do you?

Anyway, that's about as far as I can help so I wish you luck! (unless you need an idea for verifying the password is blank [if they tell you it is blank] before continuing - because I have an idea for that)

- Steven

Share this post


Link to post
Share on other sites

Well... for shredding passwords you can do some anciliarry checks to make sure the password is, in fact, blank (and then you wouldn't be shredding anything).

And if they aren't administrators... then can they run remote programs in XP? I didn't think so.

So the users that can't do it anyway don't have to worry about it because they are only doing local jobs (correct me if I'm wrong) and the ones that can do it just need a password.

Really, it seems to me then that your only worry is the local non-administrator user running a local command... at that point you don't need the RunAsSet then, do you?

Anyway, that's about as far as I can help so I wish you luck! (unless you need an idea for verifying the password is blank [if they tell you it is blank] before continuing - because I have an idea for that)

- Steven

How would you be able to check if the password on the remote (or local, depending which computer is selected) computer is in fact blank? Wouldn't that involve checking if the username is indeed valid, which would be the thing my function is trying to accomplish? The seperate program from mine isn't trying to run itself on the remote system, I don't even use RunAsSet to access the remote system. The program will connect to the system in order to obtain information, using the credentials supplied. It will accept a blank password while RunAsSet doesn't. What is your idea?

Thank you for helping me Steven!

Share this post


Link to post
Share on other sites

Sorry for the delay response but I just found this it may help you.... Post


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0