water Posted March 14, 2014 Author Share Posted March 14, 2014 This error is shown when a user doesn't have the extensionAttribute2 defined. Which version of AutoIt do you run? Which version of the AD UDF do you use? 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...
kor Posted March 14, 2014 Share Posted March 14, 2014 (edited) Running AutoIT 3.3.8.1 AD 1.4.0.0 But if a user doesn't have the extensionAttribute2 defined or it is Null why is that a COM error. And I thought my code can handle that with the line: If $sAttribute = "" Then ExitLoop Edited March 14, 2014 by kor Link to comment Share on other sites More sharing options...
water Posted March 14, 2014 Author Share Posted March 14, 2014 A COM error in this case is fine and expected. It is raised before line "If $sAttribute = "" Then ExitLoop" is being executed. Version 1.4.0.0 automatically activates a COM error handler to support all versions of AutoIt. If you insert _AD_ErrorNotify(4) before _AD_Open then the COM errors are still handled but no output is created. 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...
kor Posted March 14, 2014 Share Posted March 14, 2014 But I need the script to continue. Not fail. It stops at "d" when we have e through z users that we need to check against. I added error notify but now the script just stops at dramirez rather than continuing and checking the rest of the users. Link to comment Share on other sites More sharing options...
water Posted March 14, 2014 Author Share Posted March 14, 2014 The script doesn't fail. AD tells the script that the requested attribute isn't available by raising the COM error. The UDF handles the COM error and continues the script. What do you mean by "the script stops"? Does it crash or just hang? 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...
kor Posted March 14, 2014 Share Posted March 14, 2014 The script exits. Gracefully, but exists none the less. However if I remove the lines that call that attribute query I get about 30 more names in my array after dramirez. Link to comment Share on other sites More sharing options...
water Posted March 15, 2014 Author Share Posted March 15, 2014 Does this mean you get all expected names or just a few more? 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...
water Posted March 15, 2014 Author Share Posted March 15, 2014 (edited) BTW: Shouldn't this line If $sAttribute <> "student" Then If $iModified >= $iStudentDays Then be If $sAttribute = "student" Then If $iModified >= $iStudentDays Then because you seem to process students there. Edited March 15, 2014 by water 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...
kor Posted March 17, 2014 Share Posted March 17, 2014 Does this mean you get all expected names or just a few more? I do not get all expected names. Link to comment Share on other sites More sharing options...
water Posted March 17, 2014 Author Share Posted March 17, 2014 ExitLoop is the culprit. You stop processing the list of users when the first user without attribut extensionAttribute2 is being found. This modified version should give you the result you are looking for: #NoTrayIcon #include <AD.au3> #include <Date.au3> Global $aUsers, $sUsername, $sLogin, $sModified, $iLogin, $iModified, $sAttribute, $aResult Global $iStaffDays = 180 ; days Global $iStudentDays = 90 ; days _AD_Open() ; open connection to AD $aUsers = _AD_GetObjectsInOU("OU=Purgatory,DC=ad,DC=domain,DC=org", "(objectCategory=user)") ; read users in purgatory into an array For $i = 1 to UBound($aUsers) - 1 $sUsername = $aUsers[$i] $sModified = StringRegExpReplace(_AD_GetObjectAttribute($sUsername, "whenChanged"), "(\d{4})(\d{2})(\d{2}).+", "$1/$2/$3") ; convert YYYYMMDDHHMMSS into YYYY/MM/DD $iModified = _DateDiff("D", $sModified, _NowCalcDate()) ; compare dates $sAttribute = _AD_GetObjectAttribute($sUsername, "extensionAttribute2") If @error = 0 Then If $sAttribute = "student" Then If $iModified >= $iStudentDays Then ; if last modified is more than X days ConsoleWrite("> Deleting user " & $sUsername & @CR) _ArrayAdd($aResult, $sUsername) EndIf Else If $iModified >= $iStaffDays Then ; if last modified is more than X days ConsoleWrite("> Deleting user " & $sUsername & @CR) _ArrayAdd($aResult, $sUsername) EndIf EndIf EndIf Next _AD_Close() ; close connection to AD _ArrayDisplay($aResult) 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...
kor Posted March 17, 2014 Share Posted March 17, 2014 works as expected now. Thanks. Link to comment Share on other sites More sharing options...
water Posted March 18, 2014 Author Share Posted March 18, 2014 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...
araneon Posted March 19, 2014 Share Posted March 19, 2014 The problem follows.I have a form that would need to run my script when the user's domain, in my form inserted the user account that launched my script, the main criterion is the "Description" field in which we have prescribed AD Name Last Name First NameI apologize for distorting the description of my problem, there is no knowledge of English, use Google translator. Link to comment Share on other sites More sharing options...
water Posted March 19, 2014 Author Share Posted March 19, 2014 Example to retrieve attribute "Description" for the current user: #include <AD.au3> _AD_Open() Global $sUser = @UserName $sResult = _AD_GetObjectAttribute($sUser, "Description") If @error Then MsgBox(0, "Error", "Error " & @error & " returned when retrieving AD-information for user " & $sUser) Else MsgBox(0, "Result", "Description for user " & $sUser & ": " & $sResult) EndIf _AD_Close() Exit 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...
araneon Posted March 19, 2014 Share Posted March 19, 2014 (edited) OOOOThank you very much.That's what I needed! + Edited March 19, 2014 by araneon Link to comment Share on other sites More sharing options...
water Posted March 19, 2014 Author Share Posted March 19, 2014 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...
jazzyjeff Posted March 21, 2014 Share Posted March 21, 2014 (edited) Water, I am trying to remove a mailbox using the _AD_DeleteMailbox function, but I receive this error when executing the command: AD.au3 (3913) : ==> Variable must be of type "Object".: If $oUser.HomeMDB = "" Then Return Set Error(2, 0, 0) If$oUser^ ERROR I am using version 1.4.1 of your UDF and 3.3.10.2 of Autoit. The code I am using to delete the mailbox is this: _AD_Open() Global $iValue = _AD_DeleteMailbox(_GUICtrlListView_GetItemText($list,$i - 1)) If $iValue = 1 Then FileWriteLine($oFile,_GUICtrlListView_GetItemText($list,$i - 1) & " - User mailbox deleted.") ElseIf @error = 1 Then FileWriteLine($oFile,_GUICtrlListView_GetItemText($list,$i - 1) & " - User does not exist.") ElseIf @error = 2 Then FileWriteLine($oFile,_GUICtrlListView_GetItemText($list,$i - 1) & " - User mailbox does not exist.") Else FileWriteLine($oFile,_GUICtrlListView_GetItemText($list,$i - 1) & " - Return code '" & @error & "' from Active Directory") EndIf _AD_Close() I do have permissions to remove a mailbox from the management console, so I don't think it is a permissions issue. Edited March 21, 2014 by jazzyjeff Link to comment Share on other sites More sharing options...
water Posted March 21, 2014 Author Share Posted March 21, 2014 Which OS version do you run on the client? Which version of Exchange server do you run? 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...
jazzyjeff Posted March 21, 2014 Share Posted March 21, 2014 I am running Windows 7 x64 professional and Exchange 2010. Link to comment Share on other sites More sharing options...
water Posted March 21, 2014 Author Share Posted March 21, 2014 (edited) With the versions you run it is no longer possible to create/delete a mailbox by using the AD function. I suggest to user PowerShell to remove the mailbox. Edited March 24, 2014 by water 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