water Posted March 23, 2016 Share Posted March 23, 2016 This error codes are described in the header of each function. For _AD_GetObjectsInOU it means: Specified OU does not exist. 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 Link to comment Share on other sites More sharing options...
BigNoter Posted March 23, 2016 Share Posted March 23, 2016 I checked the path and it was OK! Global $sOU = "LDAP://OU=OUName2,OU=OUName1,OU=OUName0,DC=1,DC=2,DC=3" ; OU to process Is this the write way of FQDN? TIA Link to comment Share on other sites More sharing options...
water Posted March 23, 2016 Share Posted March 23, 2016 Should be the FQDN of the OU: Global $sOU = "OU=OUName2,OU=OUName1,OU=OUName0,DC=1,DC=2,DC=3" ; OU to process 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 Link to comment Share on other sites More sharing options...
BigNoter Posted March 23, 2016 Share Posted March 23, 2016 So why I'm getting this error? TIA Link to comment Share on other sites More sharing options...
water Posted March 23, 2016 Share Posted March 23, 2016 You did notice that I stripped off " LDAP:// "? 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 Link to comment Share on other sites More sharing options...
BigNoter Posted March 23, 2016 Share Posted March 23, 2016 Sorry, Link to comment Share on other sites More sharing options...
BigNoter Posted March 23, 2016 Share Posted March 23, 2016 20 hours ago, water said: Untested! Please make sure to test on a test system only!! #include <AD.au3> Global $sOU = "" ; OU to process Global $aObjects, $aGroups ; Open Connection to the Active Directory _AD_Open() If @error Then Exit MsgBox(16, "AD", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) ; Get a list of users in the specified OU (subtree) $aObjects = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user))", 2, "sAMAccountName,memberof") If @error > 0 Then Exit MsgBox(16, "AD", "Function _AD_GetObjectsInOU encountered a problem. @error = " & @error & ", @extended = " & @extended) ; Process all users For $i = 1 To $aObjects[0][0] $aGroups = StringSplit($aObjects[$i][1], "|") For $j = 1 To $aGroups[0] ; Remove User from group _AD_RemoveUserFromGroup($aGroups[$j], $aObjects[$i][0]) If @error > 0 Then Exit MsgBox(16, "AD", "Function _AD_RemoveUserFromGroup encountered a problem. @error = " & @error & ", @extended = " & @extended) Next ; Add User to new groups (repeat the statement for each group to be added) _AD_AddUserToGroup(">>Set groupname here<<", $aObjects[$i][0]) If @error > 0 Then Exit MsgBox(16, "AD", "Function _AD_AddUserToGroup encountered a problem. @error = " & @error & ", @extended = " & @extended) Next _AD_Close() It worked... Without any change. Thnx Link to comment Share on other sites More sharing options...
water Posted March 23, 2016 Share Posted March 23, 2016 I'm a genius It happened for the first time that a script worked without any modification 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 Link to comment Share on other sites More sharing options...
BigNoter Posted March 27, 2016 Share Posted March 27, 2016 One more question, does it modify the users in sub OUs as well? TIA Link to comment Share on other sites More sharing options...
water Posted March 27, 2016 Share Posted March 27, 2016 Sure. Parameter 3 in _AD_GetObjectsInOU defines where to search: 0 = base, 1 = one-level, 2 = sub-tree (default) 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 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