Sign in to follow this  
Followers 0
SlowCoder74

Can AutoIT determine AD group memberships?

5 posts in this topic

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



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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes, take a look at the and function _AD_GetUserGroups

Adam.

Edited by AdamUL

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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  
Followers 0