Sign in to follow this  
Followers 0
omicronx9

check AD group membership If ingroup("mygroup")

4 posts in this topic

#1 ·  Posted (edited)

Hello

Is there a way in Autoit to check a users groups membership similar to the kix opertation ingroup ?

EG : If InGroup("mygroup") then

Thanks in advance

Edited by omicronx9

Share this post


Link to post
Share on other sites



Yes there is. Please have a look at the AD function library


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

Yes there is. Please have a look at the AD function library

Thanks for the prompt reply forgive me for a stupid question:

Here is the script i wish to use the ad library with essenstially all this works i just need to figure out how to reference the AD stuff.

The requirement is to check if the user is in a group then execute based on there combo box selection.

How do i reference the call to ismemberof ?

#include <GuiConstants.au3>

#include <adfunctions.au3>

Dim $OFFICE, $CCOffice, $okbutton, $CancelButton, $Path, $CHOME, $WindowsFolder, $ProgramFolder,

Dim $ProgressBar1, $Sol6, $Version, $OSVersion, $Username

$Version = "Insolvency CORE Change Office v1.0"

$OSVersion = EnvGet("Deployos")

$UserName = EnvGet("Username")

$DefaultOffice = EnvGet("Office")

$WindowsFolder = EnvGet("HomeDrive") & EnvGet("HomePath") & "Windows"

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

; GUI

GuiCreate($Version, 250, 100)

GUISetState(@SW_SHOW)

GuiSetIcon("ipssql.exe", 0)

; COMBO

$SelectOffice = GUICtrlCreateCombo ("Pick an Office", 10,10) ; create first item

GUICtrlSetData(-1,"CORE Canberra|CORE Perth|CORE Sydney|CORE Melbourne|CORE Wagga Wagga|","Pick A Office")

GUICtrlSetFont (-1,9, 400, "Arial")

$okbutton = GUICtrlCreateButton ("OK", 10, 35 , 40, 25)

GUICtrlSetOnEvent($okbutton, "OKButton")

$Cancelbutton = GUICtrlCreateButton ("Exit", 55, 35, 40 , 25)

GUICtrlSetOnEvent($CancelButton, "Closebutton")

GUISetState(@SW_SHOW)

While 1

Sleep(20000) ; Idle around

WEnd

Func OKButton()

$Office = GUICtrlRead($SelectOffice)

Select

Case $Office = "CORE Canberra"

If IsMemberof ("Canberra Core Insolvency Shared MUsers", &) Then $CCOffice = "Canberra_Core"

DriveMapDel("F:")

sleep(1000)

DriveMapAdd("F:", "\\pdcdb02\" & $CCOffice & "$")

GUICtrlCreateLabel("Session set for " & $Office ,10,75,200,20)

Else

GUICtrlCreateLabel("You Do Not have Permission to Access " & $Office ,10,75,200,20)

EndIf

Case $Office = "CORE Perth"

If ingroup ("Perth Core Insolvency Shared MUsers") Then

$CCOffice = "Perth_Core"

DriveMapDel("F:")

sleep(1000)

DriveMapAdd("F:", "\\pdcdb02\" & $CCOffice & "$")

GUICtrlCreateLabel("Session set " & $Office ,10,75,200,20)

Else

GUICtrlCreateLabel("You Do Not have Permission to Access " & $Office ,10,75,200,20)

ENDIF

Case $Office = "CORE Sydney"

If ingroup ("Sydney Core Insolvency Shared MUsers") Then

$CCOffice = "Sydney_Core"

DriveMapDel("F:")

sleep(1000)

DriveMapAdd("F:", "\\pdcdb02\" & $CCOffice & "$")

GUICtrlCreateLabel("Session set for " & $Office ,10,75,200,20)

Else

GUICtrlCreateLabel("You Do Not have Permission to Access " & $Office ,10,75,200,20)

EndIf

Case $Office = "CORE Wagga Wagga"

If ingroup ("Sydney Core Insolvency Shared MUsers") Then

$CCOffice = "Wagga_Core"

DriveMapDel("F:")

sleep(1000)

DriveMapAdd("F:", "\\pdcdb02\" & $CCOffice & "$")

GUICtrlCreateLabel("Session set for " & $Office ,10,75,200,20)

Else

GUICtrlCreateLabel("You Do Not have Permission to Access " & $Office ,10,75,200,20)

EndIf

Case Else

MsgBox(0, "", "You didn't select an office")

EndSelect

EndFunc

Func Closebutton()

Exit

EndFunc

Share this post


Link to post
Share on other sites

Hi omicronx9,

to check if a User is member of a group I use something like (this example checks if the logged on user is member of group xyz):

If _ADIsMemberOf(_ADSamAccountNametoFQDN("xyz"),_ADSamAccountNametoFQDN(@UserName)) Then

According to the AD UDF you need the FQDN (full qualified domain name).


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

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