Jump to content
Sign in to follow this  
SlowCoder74

Can AutoIT determine AD group memberships?

Recommended Posts

SlowCoder74

I've built a script that has functionality that needs to be restricted to only users who are members of a certain Active Directory group. If AutoIT knows the username and password of a user, can it inquire for group memberships?

Share this post


Link to post
Share on other sites
Jos

Something like this or look at the AD UDF library in the Examples:

$oMyError = ObjEvent("AutoIt.Error", "ComError")
If  UserInGroup(@LogonDomain,@UserName,"Administrators") then
    msgbox(0,"Validate","User in your groupname")
Else
    msgbox(0,"Validate","User NOT in your groupname")
EndIf
Exit
; Check if User is in a group
Func UserInGroup($Domain, $UserName, $InGroup)
    Local $objUser = ObjGet("WinNT://" & $Domain & "/" & $UserName)
    For $oGroup in $objUser.Groups
        If $oGroup.Name = $InGroup Then
            Return 1
        EndIf
    Next
    Return 0
EndFunc
;COM Error function
Func ComError()
    If IsObj($oMyError) Then
        $HexNumber = Hex($oMyError.number, 8)
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc   ;==>ComError

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
AdamUL

Yes, take a look at the and function _AD_GetUserGroups

Adam.

Edited by AdamUL

Share this post


Link to post
Share on other sites
water

Use function _AD_IsMemberOf from my Active Directory UDF to check if a user is a member of a certain group.

For download please check my signature.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
SlowCoder74

Yep. Thanks guys! I got it working!

Share this post


Link to post
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
Sign in to follow this  

×