Jump to content
Sign in to follow this  
7h331337

need AUTHENTICATION help with ldap

Recommended Posts

7h331337

i have looked at the ad scripts in the forum but i still cant find one that lets you authenticate a user i need to authenticate the users password . i tryed this

Const $ADS_NAME_INITTYPE_GC = 3

$objTrans = ObjCreate("NameTranslate")

$Domain = $objTrans.InitEx($ADS_NAME_INITTYPE_GC, "", "administrator", @LogonDomain,"pass")

msgbox(0,"",$Domain)

but it didn't work

can anyone suggest anything that might work thanks

Edited by 7h331337

Share this post


Link to post
Share on other sites
Zedna

Place this at begin of your script:

Global $oMyError = ObjEvent ("AutoIt.Error", "ErrorHandler")


Func ErrorHandler()
    $HexNumber = Hex($oMyError.number, 8)
    
    MsgBox(16, "CHYBA", "Došlo k chybě!" & @CRLF & @CRLF & _
           "Popis chyby: " & @TAB & $oMyError.description & @CRLF & _
           "Win. popis:" & @TAB & $oMyError.windescription & @CRLF & _
           "Číslo řádku: " & @TAB & $oMyError.scriptline & @CRLF & _
           "Číslo chyby: " & @TAB & $HexNumber & @CRLF & _
           "Objekt: " & @TAB & $oMyError.source)
    
    SetError(1)
EndFunc

Also look at ObjEvent() in AutoIt's helpfile

Share this post


Link to post
Share on other sites
7h331337

Place this at begin of your script:

Global $oMyError = ObjEvent ("AutoIt.Error", "ErrorHandler")


Func ErrorHandler()
    $HexNumber = Hex($oMyError.number, 8)
    
    MsgBox(16, "CHYBA", "Došlo k chybě!" & @CRLF & @CRLF & _
           "Popis chyby: " & @TAB & $oMyError.description & @CRLF & _
           "Win. popis:" & @TAB & $oMyError.windescription & @CRLF & _
           "Číslo řádku: " & @TAB & $oMyError.scriptline & @CRLF & _
           "Číslo chyby: " & @TAB & $HexNumber & @CRLF & _
           "Objekt: " & @TAB & $oMyError.source)
    
    SetError(1)
EndFunc

Also look at ObjEvent() in AutoIt's helpfile

thanks for the advice it is going a lot quicker

but i still cant get it to authenticate the users password any suggestions

Edited by 7h331337

Share this post


Link to post
Share on other sites
7h331337

hi i wrote this(snippets form joshiieeii script) but it only works every second time can anyone help thanks

#include-once

Const $ADS_NAME_INITTYPE_GC = 3
Const $ADS_NAME_TYPE_NT4 = 3
Const $ADS_NAME_TYPE_1779 = 1
Dim $unlock
Dim $mgrvalue
Dim $mgrsplit
Dim $manager
Dim $mgr
Dim $title
Dim $pwdexpires
Global $username, $oMyError, $UserObJ

$objTrans = ObjCreate("NameTranslate")

Func userandpassword($username, $password)
    $oMyError = ObjEvent("AutoIt.Error", "ComError")

    If @error Then
        Return False


        $objTrans.Init($ADS_NAME_INITTYPE_GC, "", $username, @LogonDomain, $password)
        $objRootDSE = ObjGet("LDAP://RootDSE")
        $objTrans.Set($ADS_NAME_TYPE_1779, @LogonDomain)
        $objTrans.Set($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & $username & "\" & $password)
        $strUserDN = $objTrans.Get($ADS_NAME_TYPE_1779)
        $UserObJ = ObjGet("LDAP://" & $strUserDN)
        If @error Then
            Return False
        Else

            Return True



        EndIf
    EndIf
    $oMyError = ObjEvent("AutoIt.Error", "")

EndFunc   ;==>userandpassword

Func username($username)
    $oMyError = ObjEvent("AutoIt.Error", "ComError")

    If @error Then
        Return False
    Else
    


        $objTrans.Init($ADS_NAME_INITTYPE_GC, "")
        $objTrans.Set($ADS_NAME_TYPE_1779, @LogonDomain)
        $objTrans.Set($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & $username)
        $strUserDN = $objTrans.Get($ADS_NAME_TYPE_1779)
        $UserObJ = ObjGet("LDAP://" & $strUserDN)
        If @error Then
            Return False
        Else

            Return True



        EndIf
    EndIf
    $oMyError = ObjEvent("AutoIt.Error", "")


EndFunc   ;==>username
Func ComError()
    If IsObj($oMyError) Then
        $HexNumber = Hex($oMyError.number, 8)
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc   ;==>ComError
Edited by 7h331337

Share this post


Link to post
Share on other sites
water

Did you have a look at the function _ADAlternativeLogon in the adfunctions.au3 UDF?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×