TheOne23 Posted September 26, 2019 Share Posted September 26, 2019 Hi Experts / Water, I've been doing some work with AD. I am able to return specific info given a username. However, I want the input to accept a format of "Email", search AD for a match and return the username. Is this possible? I am using the AD.au3 but unable to see a function that works for this scenario. Any help will be greatly appreciated. Link to comment Share on other sites More sharing options...
seadoggie01 Posted September 26, 2019 Share Posted September 26, 2019 I think you meant 'Experts (especially water). You're excluding him from the experts there ;D TheOne23 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
water Posted September 26, 2019 Share Posted September 26, 2019 Something like this? #include <AD.au3> ; Open Connection to the Active Directory _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Global $aObjects = _AD_GetObjectsInOU("", "(ANR=john.Doe@company.com)", 2, "sAMAccountName,distinguishedName,displayname", "displayname") If @error > 0 Then Exit MsgBox(64, "", "No records found") _ArrayDisplay($aObjects) TheOne23 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 Link to comment Share on other sites More sharing options...
TheOne23 Posted September 26, 2019 Author Share Posted September 26, 2019 Hi Seadoggie01, Yeah Buddy. You're correct on that 😃 Link to comment Share on other sites More sharing options...
water Posted September 26, 2019 Share Posted September 26, 2019 2 minutes ago, seadoggie01 said: I think you meant 'Experts (especially water). I understood it this way TheOne23 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 Link to comment Share on other sites More sharing options...
TheOne23 Posted September 26, 2019 Author Share Posted September 26, 2019 Hi Water, As usual and expected, you made my day! 😎 It works like a charm! Thank you very much for your great and quick help on this. below is how I used it: _AD_Open() Global $aOL_Item = _OL_ItemFind($oOutlook, "RonaldJayson_paggao@comcast.com\Inbox\BP_Automation", $olMail, "[UnRead]=True", "", "", "EntryID","",2) $oItem = _OL_ItemGet($oOutlook, $aOL_Item[1][0], Default, "body") $oItem1 = _OL_ItemGet($oOutlook, $aOL_Item[1][0], Default, "receivedtime") $oItem2 = _OL_ItemGet($oOutlook, $aOL_Item[1][0], Default, "subject") Global $oItem3 = _OL_ItemGet($oOutlook, $aOL_Item[1][0], Default, "senderemailaddress") Global $oOL_Item = $oOutlook.Session.GetItemFromID($aOL_Item[1][0], Default) Global $oOL_Sender = $oOL_Item.Sender If $oOL_Sender.AddressEntryUserType = $olExchangeUserAddressEntry Or $oOL_Sender.AddressEntryUserType = $olExchangeRemoteUserAddressEntry Then Global $oExchangeUser = $oOL_Sender.GetExchangeUser ;MsgBox(0, "Mail", $oExchangeUser.PrimarySmtpAddress) $EmailAddress_Sender = $oExchangeUser.PrimarySmtpAddress ;MsgBox(0, "Mail", $EmailAddress_Sender) Else Global $EmailAddress_Sender1 = _ArrayToString($oItem3,"",1,1,"",1,1) $EmailAddress_Sender = StringStripWS($EmailAddress_Sender1,7) EndIf If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Global $aObjects = _AD_GetObjectsInOU("", "(ANR="& $EmailAddress_Sender &")", 2, "sAMAccountName,distinguishedName,displayname", "displayname") If @error > 0 Then Exit MsgBox(64, "", "No records found") _ArrayDisplay($aObjects) $cn1 = _ArrayToString($aObjects,"",1,1,"",1,1) Msgbox(64,"UserName: ",$cn1) _AD_Close() Link to comment Share on other sites More sharing options...
water Posted September 26, 2019 Share Posted September 26, 2019 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 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