noob62 Posted February 20, 2013 Share Posted February 20, 2013 I'm trying to look up the OU a user resides in based on the username that is in the array. I'm using the AD.au3 udf for the lookup in AD, I may be doing something wrong with the assignment of the user name. When I run the script I get the following error:======================================================== COM Error Encountered in testcsv2.0.au3 AD UDF version = 1.3.0 @AutoItVersion = 3.3.8.1 @AutoItX64 = 0 @Compiled = 0 @OSArch = X64 @OSVersion = WIN_7 Scriptline = 540 NumberHex = 000000A9 Number = 169 WinDescription = Variable must be of type 'Object'. Description = Source = HelpFile = HelpContext = 544040308 LastDllError = 0 ======================================================== Looking for some guidance. expandcollapse popup#include <array.au3> #include <AD.au3> Opt("MustDeclareVars", 1) Dim $sCSV = FileRead("C:\test.csv") Local $arr = _CsvToArray2D($sCSV) Local $n Local $row = UBound($arr) ;Converts CSV to a 2D array. Func _CsvToArray2D($sCSV) Local $aTmp = StringRegExp($sCSV & @CR, '(\V*)\v{1,2}', 3) Local $NumCols[UBound($aTmp)] For $x = 0 To UBound($aTmp) - 1 StringReplace($aTmp[$x], ",", ",") $NumCols[$x] = @extended + 1 Next Local $Max = _ArrayMax($NumCols, 1) Dim $aArr[UBound($aTmp)][$Max] For $i = 0 To UBound($aArr, 1) - 1 Local $aTemp = StringSplit($aTmp[$i], ",") For $j = 0 To $aTemp[0] - 1 $aArr[$i][$j] = $aTemp[$j + 1] Next Next Return $aArr EndFunc ;Search AD for the user OU While $n < $row Local $Group, $iAD_Security, $sAD_UserIdParam, $sAD_PasswordParam, $sAD_User, $device $device = $arr[$n][0] $sAD_User = $arr [$n][1] _AD_Open($sAD_UserIdParam = "", $sAD_PasswordParam = "", $iAD_Security = 1) $Group = _AD_GetUserPrimaryGroup($sAD_User) _AD_Close() $n = $n + 1 WEnd Link to comment Share on other sites More sharing options...
water Posted February 21, 2013 Share Posted February 21, 2013 Your _AD_Open statement is wrong. If you need a secure connection use_AD_Open("", "", "", "", "", 1) BTW: Don't do _AD_Open/_AD_Close in the While loop. Open the connection to AD, loop through your data and then close the connection. 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...
noob62 Posted February 22, 2013 Author Share Posted February 22, 2013 (edited) Thanks for the help! Just two other questions Is this the correct way to pass a user name to look up their OU in AD. For instance if $sAD_User gets set to jdoe will it pull back widget factory for the OU when it looks up jdoe in AD? $sAD_User = $arr [$n][1] $Group = _AD_GetUserPrimaryGroup($sAD_User) The second part to the last while statement will have the script write the OU to the device name via API of another product the only thing is when you access the API it prompts a windows security login for the user which is fine unless the script is looking up 50+ devices. Will the HTTP UDF allow the user to enter their credentials once so they wont have to keep inputting that information when the script is running? I know the forum rules about password stuff, I'm not trying to bypass security settings with this script Edited February 22, 2013 by noob62 Link to comment Share on other sites More sharing options...
water Posted February 22, 2013 Share Posted February 22, 2013 1) If you query user jdoe by using _AD_GetUserPrimarygroup you will get a Fully Qualified Domain Name (FQDN). If you need further properties of the user you should call _AD_GetObjectProperties and pass this FQDN. You get all or selected properties in an array. 2) Don't know. We would need more information about that. 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...
noob62 Posted February 23, 2013 Author Share Posted February 23, 2013 For instance I want the script to do the following after it gets the user OU ShellExecute("https://localhost:8081/remote/system.applyTag?names=" & $device & "&tagName=" & $Group) But when accessing the API it requires a windows security login before it will apply the tag to a device. I'm looking for a way that the user can enter their info once instead of each time the script tries to access the API. Link to comment Share on other sites More sharing options...
water Posted February 23, 2013 Share Posted February 23, 2013 It depends on the application. Either it provides a way to login, do all the needed processing and then log out. Or you need to use the IE UDF to provide the needed credentials. 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