Sign in to follow this  
Followers 0
wking10

Authentication using autoit

11 posts in this topic

Hi,

is there anyway we can script autoit to prompt domain user name and password and check it against active directory?

thanks,

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Something like this should do it: (i have posted it a few times before)

$oMyError = ObjEvent("AutoIt.Error", "ComError")
msgbox(0,"Validate",UserValidate(@LogonDomain,"unknown-user","userpwd"))
msgbox(0,"Validate",UserValidate(@LogonDomain,"Okuser","userpwd"))
msgbox(0,"Validate",UserValidate(@LogonDomain,"Okuser","userpwd","groupdoesnotexist"))
msgbox(0,"Validate",UserValidate(@LogonDomain,"Okuser","userpwd","groupexist"))
Exit
; Check Valid User/Password and optionally in a group 
Func UserValidate($domain, $UserName, $Password, $InGroup="")
    Local $NameSpace = ObjGet("WinNT:")
    Local $ADS_SECURE_AUTHENTICATION = 0x0001
; Check the userid/password combination and on error return a 0
    Local $DomObj = $NameSpace.OpenDSObject("WinNT://" & $domain , $UserName, $Password, $ADS_SECURE_AUTHENTICATION)
    If @error <> 0 Then Return 0
; Optionally check the group membership
    If $InGroup <> "" Then
        $objUser = ObjGet("WinNT://" & $Domain & "/" & $UserName)
        For $oGroup in $objUser.Groups
            If $oGroup.Name = $InGroup Then 
                Return 1
            EndIf
        Next
        Return 0
    EndIf
    Return 1
EndFunc 
;COM Error function
Func ComError()
    If IsObj($oMyError) Then
        $HexNumber = Hex($oMyError.number, 8)
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc  ;==>ComError
Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

hi Jos,

fantastic! thanks heaps! thats exactly what i need.

thanks again.

Share this post


Link to post
Share on other sites

This looks pretty good, but is there an example of how to call these functions?


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Yeah, omg Larry and Jos, way to drop the ball, guys. What were you thinking?!

:)

Edited by JRowe

Share this post


Link to post
Share on other sites

Well what I was asking was not really on an example script which I did see, but a purpose. It returns a 1 or a 0 so I was seeing how this could be useful. I guess I was just wanting to see if anyone used it in a particular way other than just what the OP asked for.

Ok this is not a dumb question. :) As I was testing it with different things, since it uses the domain policy it will lock you out after so many tries. Anyway to say how many times you have tried to autheticate? So if you have input boxes and you've tried twice. You can put, this is your 3rd or 4th attempt?

Thanks


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

I was looking for it for long

I'll give it a try.

Thanks

Share this post


Link to post
Share on other sites

@EndFunc

Every time that a login is attempted... +1 to a variable...

TryLogin()
$LoginAttempts += 1
MsgBox(0,"Attempts", "Login Attempts: " & $LoginAttempts)

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