water Posted December 14, 2016 Posted December 14, 2016 As the Active Directory UDF thread has grown too big, I start a new one. The original thread can be found here. Ivo and JackyMB 2 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
legend Posted December 19, 2016 Posted December 19, 2016 (edited) Sometimes when unlocking AD users, and only if they are locked out, I will get a error: http://i.imgur.com/x0EPzwH.png the function looks like this: Func user_unlock() _AD_Open() Local $object1 = InputBox("Brugernavn", "Indtast brugernavn", "") if @error Then Exit Local $object = StringStripWS($object1, $STR_STRIPALL) $is_locked = _AD_IsObjectLocked($object) if $is_locked = 1 Then $is_locked = "Ja" Else $is_locked = "Nej" EndIf Local $displayname = _AD_GetObjectAttribute($object, "displayName") Local $ivalue = _ad_unlockobject($object) If $ivalue = 1 Then _FileWriteToLine($programfilesdir & "\RDTray\log.txt", 1, @MDAY & "-" & @MON & "-" & @YEAR & " - " & @HOUR & ":" & @min & ":" & @SEC & " : " & "Låst op: " & $object, 0) ClipPut($object) MsgBox(64 + 262144, "Låst op", "Brugeren er blevet låst op: " & $object & @CRLF & @CRLF & "Navn: " & $displayname & @CRLF & @CRLF & "Var brugeren låst i forvejen: " & $is_locked) ElseIf @error = 1 Then MsgBox(64 + 262144, "info", "Bruger eksisterer ikke: " & $object,2) user_unlock() Else MsgBox(64 + 262144, "rettigheds problem", "Den bruger du er logget ind med, har ikke rettigheder til at låse brugeren op - Log ind på din admin konto",3) EndIf _AD_Close() EndFunc Can you see why i sometimes might get the error :)? It's not always, but only sometimes, and only if the account is locked out Edited December 19, 2016 by legend
water Posted December 19, 2016 Author Posted December 19, 2016 This has to be somewhere in your script because the AD UDF only has about 4800 lines. Use _AD_ErrorNotify(3) to write detailed error information into a log file. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
water Posted December 19, 2016 Author Posted December 19, 2016 This has to be somewhere in your script because the AD UDF only has about 4800 lines. Use _AD_ErrorNotify(3) to write detailed error information into a log file. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
legend Posted December 19, 2016 Posted December 19, 2016 The line number is because I have a lot of autoit includes, I will try to put _AD_ErrorNotify(3, "C:\log.txt") under: Local $ivalue = _ad_unlockobject($object) Thank's for your help water
water Posted December 19, 2016 Author Posted December 19, 2016 Use _AD_ErrorNotify(3, "C:\log.txt") Local $ivalue = _AD_UnlockObject($object) and make sure that you have write permission on the target directory. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
legend Posted December 19, 2016 Posted December 19, 2016 43 minutes ago, water said: Use _AD_ErrorNotify(3, "C:\log.txt") Local $ivalue = _AD_UnlockObject($object) and make sure that you have write permission on the target directory. hmm i just tried that, i tried writing to a log file on the desktop, and I got a error just now, by unlocking a locked out account, But it didn't write anything to the log file
water Posted December 19, 2016 Author Posted December 19, 2016 Which version of the AD UDF do you run? Which version of AutoIt do you run? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
legend Posted December 19, 2016 Posted December 19, 2016 (edited) both the latest one, autoit: 3.3.14.2 and AD UDF: 1.4.6.0 (note: i'm always running the script as another user. We are logged in as users without administrators or domain administrator rights) So when we need them, we use our admin accounts, can that give any problems regarding this issue :)? Edited December 19, 2016 by legend
water Posted December 19, 2016 Author Posted December 19, 2016 There is no error checking in your script. You should always check @error after calling an AD function: Func user_unlock() _AD_Open() If @error Then Exit MsgBox(0, "Error", "Error calling _AD_Open: @error = " & @error & ", @extended = " & @extended) Local $object1 = InputBox("Brugernavn", "Indtast brugernavn", "") If @error Then Exit Local $object = StringStripWS($object1, $STR_STRIPALL) $is_locked = _AD_IsObjectLocked($object) If @error Then Exit MsgBox(0, "Error", "Error calling _AD_IsObjectLocked: @error = " & @error & ", @extended = " & @extended) If $is_locked = 1 Then $is_locked = "Ja" Else $is_locked = "Nej" EndIf Local $displayname = _AD_GetObjectAttribute($object, "displayName") Local $ivalue = _AD_UnlockObject($object) If @error Then Exit MsgBox(0, "Error", "Error calling _AD_UnlockObject: @error = " & @error & ", @extended = " & @extended) If $ivalue = 1 Then _FileWriteToLine($programfilesdir & "\RDTray\log.txt", 1, @MDAY & "-" & @MON & "-" & @YEAR & " - " & @HOUR & ":" & @min & ":" & @SEC & " : " & "Låst op: " & $object, 0) ClipPut($object) MsgBox(64 + 262144, "Låst op", "Brugeren er blevet låst op: " & $object & @CRLF & @CRLF & "Navn: " & $displayname & @CRLF & @CRLF & "Var brugeren låst i forvejen: " & $is_locked) ElseIf @error = 1 Then MsgBox(64 + 262144, "info", "Bruger eksisterer ikke: " & $object,2) user_unlock() Else MsgBox(64 + 262144, "rettigheds problem", "Den bruger du er logget ind med, har ikke rettigheder til at låse brugeren op - Log ind på din admin konto",3) EndIf _AD_Close() EndFunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
legend Posted December 19, 2016 Posted December 19, 2016 Now I got an error when I tried to unlock a user object,
spudw2k Posted December 19, 2016 Posted December 19, 2016 (edited) Looking at the _IsObjectLocked source, the only time it should return an error code that is not 1 or -1 is when the object is locked and $sResetLockoutTime >= $sNow (line 1802). Edited December 19, 2016 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
legend Posted December 20, 2016 Posted December 20, 2016 9 hours ago, spudw2k said: Looking at the _IsObjectLocked source, the only time it should return an error code that is not 1 or -1 is when the object is locked and $sResetLockoutTime >= $sNow (line 1802). So it seems it's a problem with checking if the object is locked or not, When I get the error: It will unlock the user object, no matter if the error above appears or not
legend Posted December 26, 2016 Posted December 26, 2016 I'm still looking for what is causing the problem ^^ anyone got an idea what it can be?
water Posted December 26, 2016 Author Posted December 26, 2016 I'm on vacation right now. Will check after 3rd of January. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
legend Posted December 26, 2016 Posted December 26, 2016 1 hour ago, water said: I'm on vacation right now. Will check after 3rd of January. Wishing you a nice holiday, enjoy good weather hopefully
legend Posted January 4, 2017 Posted January 4, 2017 Hi Water Can you think of what my cause it, We use the unlock function everyday, but it's very often that it gives and error when the account is locked out. From what I can see it only happens when checking if the object is locked or not: _AD_IsObjectLocked I will try to remove _AD-IsObjectLocked and simply use _AD_UnlockObject, to see if the problem dissapears, however it would be nice to see if the user object was locked or not when unlocking it
water Posted January 4, 2017 Author Posted January 4, 2017 Do you use the AD fine grained password policy? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
legend Posted January 5, 2017 Posted January 5, 2017 18 hours ago, water said: Do you use the AD fine grained password policy? Yeah, i am but how should that impact checking if it's locked or not?
water Posted January 5, 2017 Author Posted January 5, 2017 _AD_IsObjectLocked retrieves the LockoutTime from AD. Then it uses function _AD_GetPasswordInfo to retrieve the Lockout Duration to calculate the time when the object gets unlocked again. The AD UDF does not support fine grained password policy - which means that this causes the current problem. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
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