ale1981 Posted September 11, 2007 Posted September 11, 2007 Hi guys, This is my first attempt at anything like this using AutoIT. Currently we use a VBS script to do the logon script on our network, but since finding AutoIT i now want to convert the functions to AutoIT. At the moment the VBS script searches through the AD for the current logged on user and then determines which group that user is in, then connects the relevant network drives and printers based on the group. I cant seem to find a function in AutoIT that does this. I found a script on here, but it was very confusing and a bit over the top as all I need is the ability to search a group for the user. Also is there a way to add network printers using AutoIT without the popup box appearing "Connecting to..." etc. Thanks for your help and look forward to converting to AutoIT!
Developers Jos Posted September 11, 2007 Developers Posted September 11, 2007 (edited) something like this ? $oMyError = ObjEvent("AutoIt.Error", "ComError") If UserInGroup(@LogonDomain,@UserName,"Your AD groupName") 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 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 Edited September 11, 2007 by JdeB 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.
ale1981 Posted September 11, 2007 Author Posted September 11, 2007 something like this ? $oMyError = ObjEvent("AutoIt.Error", "ComError") If UserInGroup(@LogonDomain,@UserName,"Your AD groupName") 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 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 Exactly like that MANY thanks JdeB
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