beb7089 Posted August 24, 2006 Posted August 24, 2006 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.
Developers Jos Posted August 24, 2006 Developers Posted August 24, 2006 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
beb7089 Posted August 24, 2006 Author Posted August 24, 2006 $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.
Developers Jos Posted August 24, 2006 Developers Posted August 24, 2006 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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