araneon Posted August 11, 2015 Posted August 11, 2015 You simply have to grab those groups you are interested in:$aGroups = _AD_RecursiveGetMemberOf(@Username, 10, False, False) For $i = 1 To $aGroups[0] If StringLeft($aGroups[$i], 9) = "RND_DB_1C" Then ; Process the group NextThank you very much for your help and for UDP super !!!I did a search through the regular expressions$sUser = _AD_RecursiveGetMemberOf(@Username, 10, False, False) $GR = _ArrayToString($sUser, @lf) $aRes = StringRegExp($GR, '(RND_DB_1C_[^\n]+)', 3) If @error Then Exit
water Posted August 11, 2015 Author Posted August 11, 2015 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 August 11, 2015 Author Posted August 11, 2015 _AD_ObjectExists? 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
mdwerne Posted August 24, 2015 Posted August 24, 2015 (edited) I'm attempting to set an attribute in AD with the following script. AD returns a '0'...and my data is not written. The attribute already has two other entries, that is why I am trying to append (3) to the attribute. Can anyone see what I may be doing wrong?expandcollapse popup#include <AD.au3> Global $UserName = @UserName, $sAltSecurityIdentities = "Test:username@somedomain.com" _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Query", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) ; Checking value before $aProperties = _AD_GetObjectProperties($UserName, "cn,altSecurityIdentities") _ArrayDisplay($aProperties, "SRN Active Directory properties for user '" & $UserName & "'") _AD_ErrorNotify(2) $iValue = _AD_ModifyAttribute($UserName, "altSecurityIdentities", $sAltSecurityIdentities, 3) MsgBox(64, "Result", "Error code: '" & @error & "' from Active Directory") ; Name...........: _AD_ModifyAttribute ; Description ...: Modifies an attribute of the given object to the value specified. ; Syntax.........: _AD_ModifyAttribute($sObject, $sAttribute[, $sValue = ""[, $iOption = 1]]) ; Parameters ....: $sObject - Object (user, group ...) to add/delete/modify an attribute (sAMAccountName or FQDN) ; $sAttribute - Attribute to add/delete/modify ; $sValue - Optional: Value to modify the attribute to. Use a blank string ("") to delete the attribute (default). ; +$sValue can be a single value (as a string) or a multi-value (as a one-dimensional array) ; $iOption - Optional: Indicates the mode of modification: Append, Replace, Remove, and Delete ; |1 - CLEAR: remove all the property value(s) from the object (default when $svalue = "") ; |2 - UPDATE: replace the current value(s) with the specified value(s) ; |3 - APPEND: append the specified value(s) to the existing values(s) ; |4 - DELETE: delete the specified value(s) from the object ; Return values .: Success - 1 ; Failure - 0, sets @error to: ; |1 - $sObject does not exist ; |x - Error returned by SetInfo method (Missing permission etc.) ; Checking value after $aProperties = _AD_GetObjectProperties($UserName, "cn,altSecurityIdentities") _ArrayDisplay($aProperties, "Active Directory Properties for user '" & $UserName & "'") _AD_Close() If $iValue = 1 Then MsgBox(64, "Result", "altSecurityIdentities for user '" & $UserName & "' was successfully modified!") ElseIf @error = 1 Then MsgBox(64, "Result", "User '" & $UserName & "' does not exist in Active Directory") Else MsgBox(64, "Result", "Error code: '" & @error & "' from Active Directory") EndIfThanks for any suggestions,-Mike Edited August 25, 2015 by mdwerne Modify variable name to minimize confusion...
water Posted August 24, 2015 Author Posted August 24, 2015 Looks like you need to pass an array with all the needed values. Unfortunatley this site is written in German but I think you'll get the message:http://www.administrator.de/frage/powershell-vbscript-altsecurityidentities-188680.html mdwerne 1 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
mdwerne Posted August 25, 2015 Posted August 25, 2015 Thanks water...I'll play with this and see if I can generate a successful "append". This is a bit more complicated than I was hoping for, but at least it's a solution and yesterday I didn't have one. Also, thanks for hunting down that website, there is no way I would have found it on my own...guess I need to stop filtering out non English websites .All the best amigo!-Mike
water Posted August 25, 2015 Author Posted August 25, 2015 I searched MSDN and got this.Here it says it is a string - so maybe the german link is wrong.I searched the forum and found this post talking about "altSecurityIdentities". Here it uses an array.I'm a bit confused 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
mdwerne Posted August 25, 2015 Posted August 25, 2015 As the array route seems like a quicker test, I'll give that a shot and post back my results...and just because I neglected to do so before, here is the debug info from the initial failure in case you see something I don't.---------------------------Active Directory Functions - Debug Info---------------------------COM Error Encountered in X.509Test.au3AD UDF version = 1.4.2@AutoItVersion = 3.3.14.1@AutoItX64 = 0@Compiled = 0@OSArch = X64@OSVersion = WIN_81Scriptline = 2590NumberHex = 80020009Number = -2147352567WinDescription = Exception occurred.Description = Unspecified errorSource = Active DirectoryHelpFile =HelpContext = 0LastDllError = 0Thanks again,-Mike
mdwerne Posted August 25, 2015 Posted August 25, 2015 WUHOO, SUCCESS!!Your previous post suggesting an array with an update (2) instead of an append (3) worked perfectly!!Posted 22 Mar 2013 by waterHow about$aAltSecurityIdentities[3] = ["String1", "String2", "String3"] _AD_ModifyAttribute($strUsername, "altsecurityidentities", $aAltSecurityIdentities, 2)Thank you for the suggestion, I am back on track!! This really is a great UDF, you and Jonathan Clelland did an excellent job...and thank you for taking the time to keep it updated.All the best,-Mike
water Posted August 25, 2015 Author Posted August 25, 2015 I'm glad the problem could be solved Now we have another example of working code if someone else is looking for it in the future! 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
Lucid Posted September 8, 2015 Posted September 8, 2015 I've got a 64-bit Windows PE image (that doesn't have the ADSI plugin installed), and I was wondering if there's an easy way to get Water's UDF to work (version 1.4.2.0) so I can communicate with Active Directory from within it?The AdFind.exe utility from Joeware works on my 32-bit WinPE image (so I know it's possible to connect to AD), but since that's only 32-bit it's not filling the void for me in my 64-bit WinPE environment. Oh, and my Autoit code works just fine in a full OS of course (or even a WinPE image with the old ADSI plugin) - just not in this slimmed down, ADSI-less, 64-bit WinPE image. Anyone run into this type of scenario and can shed some light on how I can stick with just pure Autoit code?$iResult = _AD_Open($sAccountName, $sAccountPassword, $sDNSDomain, $sPrimaryDomainControllerFQDN, $sConfiguration, $iUseSSL)Returns 0@error = 2@extended = -2147221005Thanks!P.S. I'm still sort of new to Autoit, so maybe I'm overlooking something obvious...
water Posted September 8, 2015 Author Posted September 8, 2015 @error = 2 means: Creation of the COM object to the AD failed. @extended returns error code from ObjCreateSo I assume some module is missing. I'm not familiar with Windows PE so I only can suggest to install the ADSI plugin. Or is this not a valid option? 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 September 16, 2015 Posted September 16, 2015 (edited) Hey Water, I am trying a very simple script to check group membership and I always get an error when running as non admin users, and only on certain machines. This is the script.#include<AD.au3> _ad_open() If _AD_IsMemberOf("AD_Group",@UserName) Then MsgBox(0,"Is",@UserName) Else MsgBox(0,"Is NOT",@UserName) EndIf _ad_close()This is the error that I receive.\\server\share\AutoIt3\Include\AD.au3" (550) : ==> Variable must be of type "Object".: $__oAD_Command.CommandText = "<LDAP://" & $sAD_HostServer & "/" & $sAD_DNSDomain & ">;(" & $sProperty & "=" & $sObject & ");ADsPath;subtree" $__oAD_Command^ ERROR How can I resolve this? i am running Autoit version: 3.3.14.1AD UDF version: 1.4.2 Thanks,Jeff Edited September 16, 2015 by jazzyjeff
water Posted September 16, 2015 Author Posted September 16, 2015 There seems to be a problem with _AD_Open then. Can you check the return value and @error please? 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 September 16, 2015 Posted September 16, 2015 I get Error: 4Extended: - 2147024843I tried running the _AD_Open function with my own credentials (I'm an admin on the domain) and I am still unable to get proper return on the If statement. Thanks
water Posted September 16, 2015 Author Posted September 16, 2015 Ah, error 4.Most of the time I got this when a compiled script was not run from a "secure location". Copy the file to a location where you usually run your programs from and try again. 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 September 16, 2015 Posted September 16, 2015 Thanks Water. i saw your message about Secure locations from another post after you sent this. I have made the script copy down locally, and this works. Not ideal, but it works.
water Posted September 16, 2015 Author Posted September 16, 2015 You could talk to your admins to make your directory a "secure location". 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 October 11, 2015 Author Posted October 11, 2015 Version 1.4.3.0 of the UDF has been released.Fixed problems with _AD_JoinDomain and _AD_UnJoinDomain! Thanks to user Neutro!Please test before using in production!For download please see my signature. 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