Jump to content

need AUTHENTICATION help with ldap


Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...