7h331337 Posted March 10, 2009 Share Posted March 10, 2009 (edited) 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 March 10, 2009 by 7h331337 Link to comment Share on other sites More sharing options...
Zedna Posted March 10, 2009 Share Posted March 10, 2009 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) EndFuncAlso look at ObjEvent() in AutoIt's helpfile Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
7h331337 Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) 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 helpfilethanks for the advice it is going a lot quicker but i still cant get it to authenticate the users password any suggestions Edited March 10, 2009 by 7h331337 Link to comment Share on other sites More sharing options...
7h331337 Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) hi i wrote this(snippets form joshiieeii script) but it only works every second time can anyone help thanks expandcollapse popup#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 March 10, 2009 by 7h331337 Link to comment Share on other sites More sharing options...
water Posted March 11, 2009 Share Posted March 11, 2009 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now