DrLarch Posted July 20, 2020 Share Posted July 20, 2020 Is there a quick/easy way to differentiate if a script is running as local admin vs. domain admin? IsAdmin() doesn't do this... hence the question. I need a script to behave differently depending on this. Link to comment Share on other sites More sharing options...
Earthshine Posted July 20, 2020 Share Posted July 20, 2020 (edited) https://www.autoitscript.com/wiki/Active_Directory_UDF_-_General The domain admin is granted local admin rights but you will need the active directory UDF most likely to find out if you’re a domain admin Edited July 20, 2020 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
DrLarch Posted July 20, 2020 Author Share Posted July 20, 2020 Thanks - yeah I've used the AD UDF here and there. Was kind of hoping there was a easier quicker way since the AD UDF query is a tad slow. And then I'm assuming one would have to loop through the array _AD_GetUserGroups returns looking for an appropriate OU admin group. Was kind of hoping there would be some more basic way within windows to determine this, but if the domain admin account is only granted local rights, how else would one divine this without querying AD? So rats, unless anyone else has some other trick up their sleeve. Link to comment Share on other sites More sharing options...
TheXman Posted July 20, 2020 Share Posted July 20, 2020 38 minutes ago, DrLarch said: So rats, unless anyone else has some other trick up their sleeve. You should be able to get the information by running the WHOAMI console command with the appropriate switch(es). Earthshine 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Subz Posted July 20, 2020 Share Posted July 20, 2020 _AD_IsMemberOf("Domain Admins", @Username) is the easiest method imho. Earthshine 1 Link to comment Share on other sites More sharing options...
DrLarch Posted July 20, 2020 Author Share Posted July 20, 2020 (edited) Thanks Xman, WHOAMI works great! And no AD query required... Edit: Oops, well WHOAMI would have to be used in combination with some kind of AD lookup it seems. WHOAMI just let's you know if it's a local or domain user. And regarding _AD_IsMemberOf, one would need to know the name of the domain admin group, since domain design varies. At least in the domain I work in, there really aren't any global admin accounts for security, only OU/Specific Site Admin accounts. So it still appears there's no universal way to determine if the user is a domain admin or just a user with local admin rights. Edited July 21, 2020 by DrLarch Link to comment Share on other sites More sharing options...
DrLarch Posted July 21, 2020 Author Share Posted July 21, 2020 (edited) Would be neat if there was some kind of IsAdmin() function that could return values like: 0 - Not Admin 1 - Local Admin 2 - Domain Admin But not sure that's even possible... Edited July 21, 2020 by DrLarch Link to comment Share on other sites More sharing options...
argumentum Posted July 21, 2020 Share Posted July 21, 2020 ...can't you try to do a domain admin only query and if failed, you're just local admin ? Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
spudw2k Posted July 21, 2020 Share Posted July 21, 2020 Domain Admin doesn't necessarily grant different permissions than being a local admin. For most cases, the Domain Admin group is added to devices when they are joined to a domain, but in environments with stricter security requirements, this may not be the case. I just wanted to point out that Domain Admin membership may not be a universal. Having said that, you would know your environment best and if you are sure that the domain admin group is in fact a member of local Administrator groups of all domain joined Windows computers, then enumerating if an account is a member of the Domain Admins group and/or checking the Local Administrators group (or executing permissions if elevated) is your best recourse. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
water Posted July 21, 2020 Share Posted July 21, 2020 Will check when I return to my computer if the AD UDF can help. 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...
water Posted July 21, 2020 Share Posted July 21, 2020 According to this article using net localgroup "Administrators" will return a list of local admin users. If you select all AD groups (starting with <domain\> or just by looking for a backslash) and query the members you should get a list all all users with full access to the computer. 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