Jump to content

IF/Else query for local groups


Recommended Posts

Hello,

sorry my english is not so good.... :P

i need a if/else function with a query to localgroups on an W2k3 Terminalserver.

The Server runs in a Domain and on the server are 3 localgroups with domainusers included

dependent from the loginusername i want to start a different program with autoit.

please can you help me ???

Link to comment
Share on other sites

I want to do the same thing, this is what i found :

$Name = InputBox("Group", "Login", "", "", 100, 100, 100, 100)
If @error Then Exit
If $Name = "" Then Exit
Local $objUser = ObjGet("WinNT://" & @computername & "/" & $Name)
For $oGroup in $objUser.Groups
    MsgBox(4096, "Groups", $oGroup.Name, 10)
Next

But :P it works on local account, not on DomainUser. When i change "@computername" with "@logondomain" it give me DomainGroup, not LocalGroup ...

Link to comment
Share on other sites

Look at that :P it works for me

#Include <Array.au3>
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler
Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" )
$answer = InputBox("Question", "Quel User ???", "Nom du USER", "", _
    -1, -1, 0, 0)

$objUser = ObjGet("WinNT://" & @LogonDomain & "/" & $answer)

Dim $filter[1] = ["group"]
$objDomain.Filter = $filter

local $LocalGroup =""
;~ Recupère les groupes locaux
For $aUser In $objDomain

    $objGroup = ObjGet("WinNT://" & @ComputerName & "/" & $aUSer.Name)


        For $objMember In $objGroup.Members()
            If $objMember.Name = $objUser.Name Then
                MsgBox(0,"",$objUser.Name & " est un membre de " & $objGroup.Name & @CRLF)
                ExitLoop
            EndIf
        Next
Next



;COM Error function
Func ComError()
    If IsObj($oMyError) Then
        $HexNumber = Hex($oMyError.number, 8)
        ConsoleWrite($oMyError.scriptline & '  $HexNumber = ' & $HexNumber & "Windescription is: " & $oMyError.description & "|" & $oMyError.windescription  & @lf);### Debug Console
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc;==>ComError
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...