water Posted February 22, 2017 Author Posted February 22, 2017 Does the example script I posted above work for you and return the desired result? 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
Valnurat Posted February 23, 2017 Posted February 23, 2017 For some reason _AD_GetObjectsInOU gives 1 more computer than exists. We only have 113 desktops, but end result shows 114. As mentioned in post 35 Yours sincerely Kenneth.
water Posted February 23, 2017 Author Posted February 23, 2017 This is described in the help file (or the function header in the UDF): Quote The default filter returns an array including one record for the OU itself. To exclude the OU use a different filter that doesn't include the OU e.g. "(&(objectcategory=person)(objectclass=user)(name=*))" Use $aComputersSource = _AD_GetObjectsInOU("OU=Laptops,OU=bla bla bla", "(&(objectCategory=computer)"(name=*))" 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
Valnurat Posted February 23, 2017 Posted February 23, 2017 I get an syntax error: "(&(objectCategory=computer)"( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Yours sincerely Kenneth.
water Posted February 23, 2017 Author Posted February 23, 2017 My bad. Should be: $aComputersSource = _AD_GetObjectsInOU("OU=Laptops,OU=bla bla bla", "(&(objectCategory=computer)(name=*))" 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
Valnurat Posted February 23, 2017 Posted February 23, 2017 $aComputers is empty. $aComputers = _AD_GetObjectsInOU("OU=Desktops,OU=Computers,OU=BLA,DC=org", "(&(objectCategory=computer)(name=*))") _ArrayDisplay("",$aComputers) Yours sincerely Kenneth.
water Posted February 23, 2017 Author Posted February 23, 2017 Strange. Will test tomorrow. 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
jazzyjeff Posted February 23, 2017 Posted February 23, 2017 Is it possible to retrieve group policy information from this script? Thanks.
water Posted February 23, 2017 Author Posted February 23, 2017 Short answer: No But IIRC there is a UDF available on the forum. 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
Valnurat Posted February 24, 2017 Posted February 24, 2017 9 hours ago, water said: Strange. Will test tomorrow. Sorry, I'm stupid. This will not work. _ArrayDisplay("",$aComputers) But this will. _ArrayDisplay($aComputers,"") So your filter is working. Doh. Yours sincerely Kenneth.
water Posted February 24, 2017 Author Posted February 24, 2017 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 February 24, 2017 Author Posted February 24, 2017 Quote The UDF does not support the Default keyword. Please check the wiki (section Tips & Tricks) for this. @Valnurat: The next version of the UDF will support the Default keyword 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
31290 Posted February 28, 2017 Posted February 28, 2017 Hi fellows Is there a way to get the "sAMAccountName" of an account by giving my script the "Displayname" properties that I have stored in an excel file? Thanks -31290- ~~~ Doom Shall Never Die, Only The Players ~~~
water Posted February 28, 2017 Author Posted February 28, 2017 As the Displayname is not unique (means: There could be more than one user with the same Displayname) you need to use a - time consuming - approach like this: #include <AD.au3> _AD_Open() Global $sDisplayName1 = "Doe Jane" Global $aResult = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user)(displayname=" & $sDisplayName1 & "))", 2, "samaccountname,displayname") _ArrayDisplay($aResult) To make it a bit faster you could query multiple users at once: #include <AD.au3> _AD_Open() Global $sDisplayName1 = "Doe Jane" Global $sDisplayName2 = "Schneider*" Global $aResult = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user)(|(displayname=" & $sDisplayName1 & ")(displayname=" & $sDisplayName2 & ")))", 2, "samaccountname,displayname") _ArrayDisplay($aResult) Note: The displayName attribute of user objects has no restrictions. In ADUC, this is the field labeled "Display name". It can be missing, or identical to the value for other users. However, you could also mean the Relative Distinguished Name of the user. This is also called the "Common Name" and is the value of the cn attribute of the user. It corresponds to the field labeled "Name" in ADUC. The value of the cn attribute is required must be unique in the Organizational Unit or container where the object resides. Two users can have the same value for cn if their objects are in different OU/containers. The sAMAccountName (also called the "pre-Windows 2000 logon" name, or what many people call the username or userid) must be unique in the domain. 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
31290 Posted February 28, 2017 Posted February 28, 2017 Hi Water, That is perfect, thanks a lot ~~~ Doom Shall Never Die, Only The Players ~~~
water Posted February 28, 2017 Author Posted February 28, 2017 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
david1337 Posted March 8, 2017 Posted March 8, 2017 Hi water I use this to get a list of users in the OU "Department" #include <AD.au3> _AD_Open() $Users = _AD_GetObjectsInOU("OU=Department,OU=Users,OU=topOU,DC=company,DC=local", "(objectclass=user)") _AD_Close() _ArrayDisplay($Users, "", Default, 8) Is it possible to exclude disabled users in the result?
water Posted March 8, 2017 Author Posted March 8, 2017 (edited) Extend your LDAP query to exclude those with "userAccountControl:1.2.840.113556.1.4.803:=" & $ADS_UF_ACCOUNTDISABLE Edited March 8, 2017 by water 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