Jump to content

Active Directory UDF - Help & Support (III)


water
 Share

Recommended Posts

Hi Water, 

I've attached you an error encountered when after adding groups to a computer, if I decide to add groups to an other computer, I get this error in your AD UDF.

Is that something you're aware of or is there something special to do to parry this?

Thanks :)

18-09-2015 19-37-44.jpg

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

No, I'm not aware of this problem.
Can you please post the code snippet you run?

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

 

Link to comment
Share on other sites

Sure, 

 

Here it is:

Func _Submit()
    Global $GID = GuiCtrlRead($GIDInput)
    If FileExists ($sIniFile) Then
    GUIDelete ($LoginfoGUI)
    $irunning = 0
    Else
    Global $EncryptedPwd = _Crypt_EncryptData (GuiCtrlRead($PassInput), $g_hKey, $iAlgo)
    IniWrite ($sIniFile, "ADTB", "AdminUserName", $Gid)
    IniWrite ($sIniFile, "ADTB", "AdminPassword", $EncryptedPwd)
    IniWrite ($sIniFile, "ADTB", "DomainName", "DC=sealedair,DC=corp")
    IniWrite ($sIniFile, "ADTB", "DomainController", "EPEDC02.sealedair.corp")
    IniWrite ($sIniFile, "ADTB", "ConfigurationContext", "CN=Configuration,DC=sealedair,DC=corp")
    $irunning = 0
    EndIf
EndFunc

Func activeDirectoryMainGUI()
decryptPwd()
$sT0_AdminUserName = IniRead($sIniFile, "ADTB", "AdminUserName", "")
$sT0_AdminUserPassword = $ClearPwd
$sT0_DomainName = IniRead($sIniFile, "ADTB", "DomainName", "")
$sT0_DomainController = IniRead($sIniFile, "ADTB", "DomainController", "")
$sT0_ConfigurationContext = IniRead($sIniFile, "ADTB", "ConfigurationContext", "")
SplashTextOn ("", "Testing connection to Domain Controller", 400, 100, -1, -1,  33, -1, -1, 700)
_AD_Open($sT0_AdminUserName, $sT0_AdminUserPassword, $sT0_DomainName, $sT0_DomainController, $sT0_ConfigurationContext)
SplashOff()
If @error Then
Msgbox (0, "", "Either DC cannot be joined or you don't have any accesses!")
Else
SplashTextOn ("", "Connection SUCCESSFUL, loading next stage...", 400, 100, -1, -1,  33, -1, -1, 700)
Sleep(2000)
SplashOff()
Endif
Global $addDefaultGroupsGUI = GUICreate("AD GROUPS", 300, 300, -1, -1)
GUICtrlCreatePic ($resources & "\SAClogo.jpg", 30, 10, 240, 80)
GUISetFont(8.5, 700, 0)
GUISetBkColor ($Color_White)
GUICtrlCreateLabel("Active Directory TOOLBOX", 85, 100, 150, 25)
GUICtrlCreateLabel("Enter the computer you want to add Default Groups:", 10, 130)
GUISetIcon ($resources & "AddDefaultGroups.ico")
GUICtrlCreateLabel("COMPUTER #:", 10, 170)
Global $ComputerInput = GUICtrlCreateInput("", 100, 168, 80, 20,$GUI_FOCUS)
GUICtrlCreateButton("ADD DEFAULT GROUPS", 86, 220)
GUICtrlSetOnEvent(-1,"addDefaultGroups")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $addDefaultGroupsGUI)
GUISetState()
$iRunning = 1
While $iRunning = 1
Sleep (10)
Wend
EndFunc

Func decryptPwd()
    Global $ClearPwd = IniRead ($sIniFile, "ADTB", "AdminPassword", "")
    Global $DecryptedPwd = _Crypt_DecryptData($ClearPwd, $g_hKey, $CALG_RC4)
    Global $ClearPwd = BinaryToString($DecryptedPwd)
    $iRunning = 0
EndFunc

Func addDefaultGroups()
Global $sGroup0 = "APP - 7Zip - 7Zip 9.2"
Global $sGroup1 = "APP - IBM - Notes 7.0.3 - W7"
Global $sGroup2 = "APP - RWD Info Pak - Help Launchpad ActiveX 5.71"
Global $sGroup3 = "APP - VideoLAN - VLC Media Player 2.0.3"
Global $sGroup4 = "APP - Code42 - Crash Plan Pro 3.6.3 - 32-64 EMEA"

;APP - IBM - Notes 7.0.3 - W7;APP - RWD Info Pak - Help Launchpad ActiveX 5.71;APP - VideoLAN - VLC Media Player 2.0.3;APP - Code42 - Crash Plan Pro 3.6.3 - 32-64 EMEA"

Global $sComputer = (GUICtrlRead($ComputerInput) & "$")

Global $iValue = _AD_AddUserToGroup($sGroup0, $sComputer)
Global $iValue = _AD_AddUserToGroup($sGroup1, $sComputer)
Global $iValue = _AD_AddUserToGroup($sGroup2, $sComputer)
Global $iValue = _AD_AddUserToGroup($sGroup3, $sComputer)
Global $iValue = _AD_AddUserToGroup($sGroup4, $sComputer)

$sComputer = StringTrimRight($sComputer, 1)

If $iValue = 1 Then
    MsgBox(64, "Done", "Computer " & $sComputer & " successfully assigned to groups: " & @CRLF & @CRLF & $sGroup0 & @CRLF & $sGroup1 & @CRLF & $sGroup2 & @CRLF & $sGroup3 & @CRLF & $sGroup4)
ElseIf @error = 1 Then
    MsgBox(64, "ERROR", "Group '" & $sGroup & "' does not exist")
ElseIf @error = 2 Then
    MsgBox(64, "ERROR", "User '" & $sComputer & "' does not exist")
; ElseIf @error = 3 Then
    ; MsgBox(64, "ERROR", "User '" & $sComputer & "' is already a member of groups '" & $sGroup & "'")
; Else
    MsgBox(64, "ERROR", "Return code '" & @error & "' from Active Directory")
EndIf
;If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)


; Returns a recursively searched list of groups the currently logged on user is a member of
;$aUser = _AD_GetUserGroups(@ComputerName & "$")
;If @error > 0 Then
  ;  MsgBox(64, "Active Directory Functions - Example 1", "User '" & @UserName & "' has not been assigned to any group")
;Else
    ; For groups that are inherited, the return is the FQDN of the group or user, and the FQDN(s) of the group(s) it
    ; was inherited from, seperated by '|'
    ;_ArrayDisplay($aUser, "Active Directory Functions - Example 1 - Group names user '" & @ComputerName & "' is a member of")
;EndIf

; Close Connection to the Active Directory
_AD_Close()
EndFunc

Func _exit()
    Exit
EndFunc

FWI, the error also occurs when compiling the script.

Hope this helps.

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

Don't know what is going on, but the following line definitely does not work:

_AD_Open(...)
SplashOff()
If @error Then
    Msgbox (0, "", "Either DC cannot be joined or you don't have any accesses!")
...

You are checking the error for SplashOff not _AD_Open. Move SplashOff after the error checking.

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

 

Link to comment
Share on other sites

Your error checking after _AD_AddUserToGroup only displays an error when the last call fails. All other calls to the function returning an error go unnoticed.
I suggest to use an array:

Global $aGroup[] = ["APP - 7Zip - 7Zip 9.2", "APP - IBM - Notes 7.0.3 - W7", "APP - RWD Info Pak - Help Launchpad ActiveX 5.71", "APP - VideoLAN - VLC Media Player 2.0.3", "APP - Code42 - Crash Plan Pro 3.6.3 - 32-64 EMEA"]

Global $sComputer = GUICtrlRead($ComputerInput)
For $i = 0 to UBound($aGroup, 1) - 1
    $iValue = _AD_AddUserToGroup($sGroup[$i], $sComputer & "$")
    If @error = 0 Then
        $iValue = $iValue + 1
    ElseIf @error = 1 Then
        MsgBox(64, "ERROR", "Group '" & $sGroup & "' does not exist")
    ElseIf @error = 2 Then
        MsgBox(64, "ERROR", "User '" & $sComputer & "' does not exist")
    ElseIf @error = 3 Then
        MsgBox(64, "ERROR", "User '" & $sComputer & "' is already a member of groups '" & $sGroup & "'")
    Else
        MsgBox(64, "ERROR", "Return code '" & @error & "' from Active Directory")
    EndIf
Next
If $iValue = UBound($aGroup, 1) Then
    MsgBox(64, "Done", "Computer " & $sComputer & " successfully assigned to all groups!")
EndIf

 

Edited 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

 

Link to comment
Share on other sites

Hi Water, 

Thanks for your quick reply.

Yes, an array is a good idea for that, I would have written it after my tests. Regarding the Splashoff() I have no other choices as you can't have a button on it to dismiss the splashoff. 

The only thing I can do is:

_AD_Open($sT0_AdminUserName, $sT0_AdminUserPassword, $sT0_DomainName, $sT0_DomainController, $sT0_ConfigurationContext)
If @error Then
Msgbox (0, "", "Either DC cannot be joined or you don't have any accesses!")
SplashOff()
Else
SplashTextOn ("", "Connection SUCCESSFUL, loading next stage...", 400, 100, -1, -1,  33, -1, -1, 700)
Sleep(2000)
SplashOff()
Endif

Unless you see something else.

Regarding the snippet you gave me (thanks BTW) I got the following error which I don't understand.

Thanks for your help.

18-09-2015 19-37-44.jpg

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

My bad. Should be

$iValue = _AD_AddUserToGroup($aGroup[$i], $sComputer & "$")

as I changed the variables prefix.

Edited 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

 

Link to comment
Share on other sites

Thanks, after declaring the variable, all is working. But what's strange is that only the first app of the array is added to the computer.

Also, the error related to the AD UDF I mentioned earlier still appears when I want to add groups to an other computer. I'm forced to close my soft and reopen it...

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

Thanks, after declaring the variable, all is working. But what's strange is that only the first app of the array is added to the computer.

But you get the message "Computer " & $sComputer & " successfully assigned to all groups!"?

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

 

Link to comment
Share on other sites

But you get the message "Computer " & $sComputer & " successfully assigned to all groups!"?

No, that's what I'm working on by adding msgboxes to see what's going on but I can't figure that out

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

Did I already ask which version of

  • the AD UDF
  • AutoIt

you run?

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

 

Link to comment
Share on other sites

This should work better:

Global $aGroup[] = ["APP - 7Zip - 7Zip 9.2", "APP - IBM - Notes 7.0.3 - W7", "APP - RWD Info Pak - Help Launchpad ActiveX 5.71", "APP - VideoLAN - VLC Media Player 2.0.3", "APP - Code42 - Crash Plan Pro 3.6.3 - 32-64 EMEA"]

Global $sComputer = GUICtrlRead($ComputerInput)
Global $iCount = 0
For $i = 0 to UBound($aGroup, 1) - 1
    _AD_AddUserToGroup($sGroup[$i], $sComputer & "$")
    If @error = 0 Then 
        $iCount = $iCount + 1
    ElseIf @error = 1 Then
        MsgBox(64, "ERROR", "Group '" & $sGroup & "' does not exist")
    ElseIf @error = 2 Then
        MsgBox(64, "ERROR", "User '" & $sComputer & "' does not exist")
    ElseIf @error = 3 Then
        MsgBox(64, "ERROR", "User '" & $sComputer & "' is already a member of groups '" & $sGroup & "'")
    Else
        MsgBox(64, "ERROR", "Return code '" & @error & "' from Active Directory")
    EndIf
Next
If $iCount = UBound($aGroup, 1) Then
    MsgBox(64, "Done", "Computer " & $sComputer & " successfully assigned to all groups!")
EndIf

 

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

 

Link to comment
Share on other sites

Did I already ask which version of

  • the AD UDF
  • AutoIt

you run?

No you did not asked but I did not tell it either :)

So, AD UDF Version ...: 1.4.2.0 (right from the au3)
And Autoit version is: 3.3.14.1

And I downloaded the AD 1.4.2.0.zip For AutoIt >= 3.3.10.2 as mentionned in your Active directory UDF post.

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

So now you get all 5 groups added to the specified computer but as soon as you try to run the script for another computer it crashes?

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

 

Link to comment
Share on other sites

So now you get all 5 groups added to the specified computer but as soon as you try to run the script for another computer it crashes?

Yes all groups are added, that's perfect. And as you said, as soon I try for another computer, I got the error mentionned by the AD UDF and I have to relaunch my soft.

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

I'm sure this problem is caused by the last line of function addDefaultGroups where you call _AD_Close().
Move this function call to the end of your script before you Exit.

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

 

Link to comment
Share on other sites

I'm sure this problem is caused by the last line of function addDefaultGroups where you call _AD_Close().
Move this function call to the end of your script before you Exit.

Func _exit()
_AD_Close()
    Exit
EndFunc

It's working perfectly! Huge relief, thanks a lot for your help. 

May I repost here if I ever need help sometimes with your UDF? (and I think this will happen ^^)

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

Sure :)

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

 

Link to comment
Share on other sites

Hi Water, 

I have a quick question for you if you don't mind:

In my script, I gather information on a user I search for, using the login name. In the AD console, If I search for my last name, 2 results are displayed. If I do the same within my script, it says that it does not exist.

Here's my function:

unc userMainGui()
GUIDelete($chooseComputerTypeGUI)
Global $userMainGui = GUICreate("AD GROUPS - USERS", 300, 300, -1, -1)
GUICtrlCreatePic ($resources & "\SAClogo.jpg", 30, 10, 240, 80)
GUISetFont(8.5, 700, 0)
GUISetBkColor ($Color_White)
GUICtrlCreateLabel("Active Directory TOOLBOX", 85, 100, 150, 25)
GuiCtrlCreateSeperator(0, 10, 120, 2, 280)
GUICtrlCreateLabel("--- USERS ---", 112.5, 130)
GUICtrlSetColor(-1, $COLOR_PURPLE)
Global $GIDInput = GUICtrlCreateInput("", 130, 168, 80, 20)
GUICtrlCreateLabel("-End User Global ID:", 10, 170)
GUICtrlSetColor(-1, $COLOR_RED)
$userMainGUISubmitBtn = GUICtrlCreateButton ("Search", 100, 260, 100, 25,$BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent($userMainGUISubmitBtn, "userSummaryandActions")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $userMainGui)
GUISetState()
EndFunc

Func userSummaryandActions()
Global $currentUser = GUICtrlRead($GIDInput)
GUIDelete($userMainGui)
Global $userSummaryandActionsGUI = GUICreate("AD GROUPS - " & $currentUser & " SUMMARY", 300, 300, -1, -1)
GUICtrlCreatePic ($resources & "\SAClogo.jpg", 30, 10, 240, 80)
GUISetFont(8.5, 700, 0)
GUISetBkColor ($Color_White)
GUICtrlCreateLabel("Active Directory TOOLBOX", 85, 100, 150, 25)
GuiCtrlCreateSeperator(0, 10, 120, 2, 280)
GUICtrlCreateLabel("--- USERS ---", 112.5, 130)
GUICtrlSetColor(-1, $COLOR_PURPLE)
GuiCtrlCreateLabel("Active Directory summary for " & $currentUser & " :", 45, 150)
$sUserFullName = _AD_GetObjectAttribute($currentUser, "displayName")
$sUseremail = _AD_GetObjectAttribute($currentUser, "mail")
If $sUseremail = "" Then $sUseremail = "email not found"
GuiCtrlCreateLabel("User's full name: " & $sUserFullName, 5, 170)
GuiCtrlCreateLabel("User's email: " & $sUseremail, 5, 190)
; $aUser = _AD_GetGroupMemberOf($currentUser)
 ; _ArrayDisplay($aUser)
MsgBox(0, "", $sUserFullName & @CRLF & $sUseremail)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $userSummaryandActionsGUI)
GUISetState()
EndFunc

What I want to do is also be able to search by last name, and if more than one, display the results and be able to choose the correct name (with a radio button for example. I don't get the logic that has to be applied here so can you please give me a hand over here?

Thanks for your help & time :)

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

To search for name related AD properties you could use ANR.(Ambigous Name Resolution).
Example 3 in the example script _AD_GetObjectsInOU.au3 shows you how to do.

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

 

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

×
×
  • Create New...