Sign in to follow this  
Followers 0
beb7089

Member of Active Directory Group

4 posts in this topic

I'm trying to code into a script some code that checks AD group membership for a specific group before executing the script. Any ideas would be greatly appreciated.

Share this post


Link to post
Share on other sites



I'm trying to code into a script some code that checks AD group membership for a specific group before executing the script. Any ideas would be greatly appreciated.

$oMyError = ObjEvent("AutoIt.Error", "ComError")
msgbox(0,"Validate",UserInGroup(@LogonDomain,"usernamer","groupname"))
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

$oMyError = ObjEvent("AutoIt.Error", "ComError")
msgbox(0,"Validate",UserInGroup(@LogonDomain,"usernamer","groupname"))
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
Where do I place the AD group name to verify? Can't make it run as-is.

Share this post


Link to post
Share on other sites

Where do I place the AD group name to verify? Can't make it run as-is.

all you need to do is change this line:

msgbox(0,"Validate",UserInGroup(@LogonDomain,"usernamer","groupname"))oÝ÷ ÚÚ,¢g­)à)jëh×6If  UserInGroup(@LogonDomain,@UserName,"Your AD groupNamee") then
    msgbox(0,"Validate","User in your groupname")
Else
    msgbox(0,"Validate","User NOT in your groupname")
EndIf

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

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