Jump to content

An invalid dn syntax has been specified


Recommended Posts

Hi guys,

Sorry if this has already been answered, i have not been able to make sense of the other posts in regards to this.

Here is my code

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <AD.au3>
#include <ButtonConstants.au3>
#include <guilistview.au3>

Global $gui2,$in1
Opt("GUIOnEventMode", 1)

    $gui2 = GUICreate("Computer Software List", 270, 550)
    GUISetOnEvent($gui_event_close, "killgui")
    GUISetState(@SW_SHOW, $gui2)
    GUISetIcon(@ScriptDir & "\resource\images\1.ico")
    $in1 = GUICtrlCreateListView("", 5, 5, 260, 495, $LVS_SORTASCENDING)
    $col = _GUICtrlListView_InsertColumn($in1, 0, "Software", 200)
    _GUICtrlListView_SetColumnWidth(-1, 0, 250)
    GUICtrlSetFont($in1, 10, "", "", "cambria")
    GUICtrlCreateButton("Show Full Name",5,505,260,40)
    GUICtrlSetFont(-1, 14, "", "", "cambria")
    GUICtrlSetOnEvent(-1,"selectedsoftware")

getsoftgroups()

Func getsoftgroups()
    $sAD_User = @ComputerName & "$"
    $fAD_IncludePrimaryGroup = 0
    _ad_open()
    $groups = _AD_GetUserGroups($sAD_User,$fAD_IncludePrimaryGroup)
        _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($in1))
        For $elements In $groups
        $convert = _AD_FQDNToDisplayname($elements)
        _GUICtrlListView_AddItem($in1,$convert)
        Next
    _ad_close()
EndFunc   ;==>gettasks

Func selectedsoftware()
    $arselect = _GUICtrlListView_GetSelectedIndices($in1, "True")
    If $arselect[0] = "" Then
        MsgBox(262160, "Error", "No Selection")
    Else
        $process = _GUICtrlListView_GetItemText($in1, $arselect[1])
        MsgBox(262208,"Software Information",$process,20)
    EndIf
EndFunc   ;==>kill

Func killgui()
    Exit
EndFunc

While 1
sleep(10)
WEnd

I get the error code listed in the title, however the code still executes if i press ok on the error and it returns the correct information as well.

I have checked the line in the AD.au3 script it is referring to which is: (Return ObjGet($sAD_FQDN)) do i need to change this?

Any help will be much appreciated, thanks in advance.

Nav

Link to comment
Share on other sites

Hi Naveed,

the array returned by _AD_GetUserGroups has the number of elements in row 0.

Your script feeds the number of elements as an FQDN to _AD_FQDNToDisplayname. Hence the error.

Change the loop to:

For $i = 1 To $groups[0]
 $convert = _AD_FQDNToDisplayname($groups[$i])
 _GUICtrlListView_AddItem($in1,$convert)
 Next

and the error is gone.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Hi Naveed,

the array returned by _AD_GetUserGroups has the number of elements in row 0.

Your script feeds the number of elements as an FQDN to _AD_FQDNToDisplayname. Hence the error.

Change the loop to:

For $i = 1 To $groups[0]
 $convert = _AD_FQDNToDisplayname($groups[$i])
 _GUICtrlListView_AddItem($in1,$convert)
 Next

and the error is gone.

That is excellent, i have just tested it and it works, Thank you very much for that, you are my HERO...... :blink:
Link to comment
Share on other sites

you are my HERO...... ;)

Thanks for that :blink:

That's the best I've heard today!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...