jp10558 Posted July 31, 2012 Posted July 31, 2012 Nevermind. I'm an idiot. I forgot that it was returning an array...
water Posted July 31, 2012 Author Posted July 31, 2012 I thought it had to be something like that ... I mean the array 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
vagabond719 Posted August 10, 2012 Posted August 10, 2012 I am sorry if this is the wrong area for this question. It seemed to be the most valid. If I run the code below I get this result: LDAP://aserver.some.company.com/ou=profile,o=some,o=company.com/cn=bserver,ou=profile,o=some,o=company.com If I change the output values to "cn, netgroup" I get a blank output box. I have spoken with our unix admin and he has confirmed that my query looks correct when using this query "<LDAP://aserver.some.company.com/ou=profile,o=some,o=company.com>;(cn=bserver);cn, netgroup". However when he runs the query he shows three values returned in the logs. When I run my query the logs only show one value returned. The LDAP I am trying to connect to is a Sun-Directory-Server. Any direction you can offer would be greatly appreciated. **************My code************** $oAD_Connection = ObjCreate("ADODB.Connection") $oAD_Connection.ConnectionString = "Provider=ADsDSOObject" $oAD_Connection.Properties("User ID") = "adminid=myid,ou=administrators,o=some,o=company.com" $oAD_Connection.Properties("Password") = "Password" $oAD_Connection.Properties("Encrypt Password") = False $oAD_Connection.Open() $oAD_Command = ObjCreate("ADODB.Command") $oAD_Command.ActiveConnection = $oAD_Connection $oAD_Command.CommandText = "<LDAP://aserver.some.company.com/ou=profile,o=some,o=company.com>;(cn=bserver);*" $com = $oAD_Command.Execute While Not $com.EOF For $field In $com.fields msgbox(0, "", $field.value) Next $com.MoveNext WEnd $oAD_Connection.Close()
water Posted August 10, 2012 Author Posted August 10, 2012 Unfortunately the UDF is for Active Directory only. I'm not familiar with the Sun Directory Server and the syntax that is used to access it. I would recommend to add a COM error handler to your script to grab any errors and display the reason. Have a look at the "ObjEvent" function in the help file. 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
xterix Posted August 13, 2012 Posted August 13, 2012 (edited) Hello water, I'm figthing with a code without sucess. I need to join an ad-group from one domain as memberof other group in other domain. the code: $OpenAD=_AD_Open($sAD_UserIdParam, $sAD_PasswordParam, $Path, $sAD_HostServerParam, $Path) ; I use data from one domain or the other. $result_Adhierarchy=_AD_AddUserToGroup("cn="&$ad_group_install&","&$FQDN_destinationdom],"cn="&$ad_group_install&","&$FQDN_client_Group) If configure _ad_open to read the destination domain @error tells that is not able to find the client group if configure _ad_open to read the client domain @error tells that is not able to find the target/destination group. AD infrastructure is ok Any idea how to solve that ? Thanks in advance. Edited August 13, 2012 by xterix
water Posted August 13, 2012 Author Posted August 13, 2012 Hello xterix,unfortunately the AD UDF doesn't support cross domain processing as you would like to do. Please see the wiki about basic concepts for the UDF. 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
xterix Posted August 13, 2012 Posted August 13, 2012 Hello xterix,unfortunately the AD UDF doesn't support cross domain processing as you would like to do. Please see the wiki about basic concepts for the UDF.Thank you mate, thanks for the quick reply.Will try to find other way of doing it
Iceman682 Posted August 23, 2012 Posted August 23, 2012 Hi Everyone, appologies in advance if this has been raised before, but I am struggling adding the OU description to a AD update tool. Not sure where the commands go or what they are: Basically my the script work great but I am in need of adding the OU description when the OU tree is populated. Not sure if it goes in here or Func GetOUTreeView() Local $Msg, $hSelection Local $sOU = "OU=EMEA,DC=mydomain,DC=net" ; FQDN of the OU where to start Local $sTitle = "EMEA Active Direcory OU Treeview" #region ### START Koda GUI section ### Form= Local $hGUI2 = GUICreate($sTitle, 743, 683, -1, -1, Default, Default, $hGUI) Global $sFile = "C:UsersUserNameDownloads1345319715_clone-4.ico" GUISetIcon($sFile) ; will change icon Local $hTree = GUICtrlCreateTreeView(6, 6, 600, 666, -1, $WS_EX_CLIENTEDGE) Local $bExit = GUICtrlCreateButton("Exit", 624, 8, 97, 33) Local $bExpand = GUICtrlCreateButton("Expand", 624, 56, 97, 33) Local $bCollapse = GUICtrlCreateButton("Collapse", 624, 104, 97, 33) Local $bSelect = GUICtrlCreateButton("Select OU", 624, 152, 97, 33) #endregion ### END Koda GUI section ### Local $aTreeView = _AD_GetOUTreeView($sOU, $hTree, True) If @error <> 0 Then MsgBox(16, "EMEA Active Direcory OU Treeview", "Error creating list of OUs starting with '" & $sOU & "'." & @CRLF & _ "Error returned by function _AD_GetALLOUs: @error = " & @error & ", @extended = " & @extended) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE, $bExit GUIDelete($hGUI2) Return "" Case $bExpand _GUICtrlTreeView_Expand($hTree) Case $bCollapse _GUICtrlTreeView_Expand($hTree, 0, False) Case $bSelect $hSelection = _GUICtrlTreeView_GetSelection($hTree) For $i = 1 To $aTreeView[0][0] If $hSelection = $aTreeView[$i][2] Then ExitLoop Next GUIDelete($hGUI2) Return $aTreeView[$i][1] EndSwitch WEnd EndFunc ;==>GetOUTreeView if it goes somewhere in here Func _AD_GetOUTreeView($sAD_OU, $hAD_TreeView, $bAD_IsADOpen = False) If $bAD_IsADOpen = False Then _AD_Open() If @error Then Return SetError(@error, @extended, 0) EndIf Local $sSeparator = "", $aAD_Temp, $sAD_Line, $iAD_Level Local $aAD_OUs = _AD_GetAllOUs($sAD_OU, $sSeparator) If @error <> 0 Then Return SetError(@error, @extended, 0) Local $aAD_TreeView[$aAD_OUs[0][0] + 1][3] = [[$aAD_OUs[0][0], 3]] For $i = 1 To $aAD_OUs[0][0] $aAD_Temp = StringSplit($aAD_OUs[$i][0], $sSeparator) $aAD_TreeView[$i][0] = StringFormat("%" & $aAD_Temp[0] - 1 & "s", "") & "#" & $aAD_Temp[$aAD_Temp[0]] $aAD_TreeView[$i][1] = $aAD_OUs[$i][1] Next If $bAD_IsADOpen = False Then _AD_Close() _GUICtrlTreeView_BeginUpdate($hAD_TreeView) Local $ahAD_Node[50] For $iAD_Index = 1 To $aAD_TreeView[0][0] $sAD_Line = StringSplit(StringStripCR($aAD_TreeView[$iAD_Index][0]), @TAB) $iAD_Level = StringInStr($sAD_Line[1], "#") If $iAD_Level = 0 Then ExitLoop If $iAD_Level = 1 Then $ahAD_Node[$iAD_Level] = _GUICtrlTreeView_Add($hAD_TreeView, 0, StringMid($sAD_Line[1], $iAD_Level + 1)) $aAD_TreeView[$iAD_Index][2] = $ahAD_Node[$iAD_Level] Else $ahAD_Node[$iAD_Level] = _GUICtrlTreeView_AddChild($hAD_TreeView, $ahAD_Node[$iAD_Level - 1], StringMid($sAD_Line[1], $iAD_Level + 1)) $aAD_TreeView[$iAD_Index][2] = $ahAD_Node[$iAD_Level] EndIf Next _GUICtrlTreeView_EndUpdate($hAD_TreeView) Return $aAD_TreeView EndFunc ;==>_AD_GetOUTreeView or if it goes in the AD.au3 script which is top notch BTW Any advice is most welcome Many thanks Iceman682
water Posted August 23, 2012 Author Posted August 23, 2012 Do you want to show the description of the OU right to the name or instead of the OU? 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
Iceman682 Posted August 23, 2012 Posted August 23, 2012 Thanks for the speedy reply Water To the Right of the OU would be ideal
Iceman682 Posted August 23, 2012 Posted August 23, 2012 As an after thought, both to the right of the OU and instead of the OU would be interesting, then I could decide which one would best suite.
water Posted August 23, 2012 Author Posted August 23, 2012 I can't test at the moment but the relevant code segments hould look like:For $iAD_Index = 1 To $aAD_TreeView[0][0] $sAD_Line = StringSplit(StringStripCR($aAD_TreeView[$iAD_Index][0]), @TAB) $iAD_Level = StringInStr($sAD_Line[1], "#") If $iAD_Level = 0 Then ExitLoop $sDescription = _AD_GetobjectAttribute($aAD_OUs[$i][1], "description") ; <=== If $iAD_Level = 1 Then $ahAD_Node[$iAD_Level] = _GUICtrlTreeView_Add($hAD_TreeView, 0, StringMid($sAD_Line[1], $iAD_Level + 1) & " " & $sDescription) ; <=== $aAD_TreeView[$iAD_Index][2] = $ahAD_Node[$iAD_Level] Else $ahAD_Node[$iAD_Level] = _GUICtrlTreeView_AddChild($hAD_TreeView, $ahAD_Node[$iAD_Level - 1], StringMid($sAD_Line[1], $iAD_Level + 1)& " " & $sDescription) ; <=== $aAD_TreeView[$iAD_Index][2] = $ahAD_Node[$iAD_Level] EndIf Next 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
Iceman682 Posted August 23, 2012 Posted August 23, 2012 Thanks Water Would this be placed in the AD.au3 script?
water Posted August 23, 2012 Author Posted August 23, 2012 No, it's part of function _AD_GetOUTreeView (replace the loop with the code I posted) and needs to be part of your script. 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
Iceman682 Posted August 23, 2012 Posted August 23, 2012 I was just going to post that I found where it goes and then read you reply You did mention that it's not tested, however I'm getting a error: F:AD Update ToolADAT-EMEA-Experimental.au3 (380) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $sDescription = _AD_GetobjectAttribute($aAD_OUs[$i][1], "description") $sDescription = _AD_GetobjectAttribute(^ ERROR Still struggling I'm afraid
water Posted August 23, 2012 Author Posted August 23, 2012 I will need to do some testing on my windows system. Will come back with a solution soon ... 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
Iceman682 Posted August 23, 2012 Posted August 23, 2012 Hi Water, found the issue and resolved $sDescription = _AD_GetobjectAttribute($aAD_OUs[$iAD_Index][1], "description") ; <===Many thanks for your assistanceIceman682
water Posted August 23, 2012 Author Posted August 23, 2012 I see, my bad. Glad you got the problem solved 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
Iceman682 Posted August 23, 2012 Posted August 23, 2012 Water, Is there any way to have all the OU descriptions line up equally? I've tried normal spaces but as you are aware due to letters having different widths the OU descriptions are all over. Many thanks Iceman682
Recommended Posts