Jump to content
Sign in to follow this  
ale1981

Active Directory Groups

Recommended Posts

ale1981

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!

Share this post


Link to post
Share on other sites
Jos

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 by JdeB

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
ale1981

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 :)

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  

×