Jump to content

Recommended Posts

Posted

K, this is what I found out, it seems that using WinNT I can't pull the same com objects as I can in LDAP looking at this site http://www.rlmueller.net/Name_Attributes.htm . So I guess I am back at the beginning where I started with .IsAccountLocked not working. I have to figure out how to get that field as a variable in order for it to work as the previous code doesn't want to work. I wish I knew why.......

Posted

Anyway to get Global Group Membership lists using this method?

Please bear with me as I'm new to Autoit, But have have put this together and it seem to work for me to get group membership, it's not the cleanest code but should give you a general idea.

#include <GUIConstants.au3>
#Include <GuiListView.au3>

Const $ADS_NAME_INITTYPE_GC = 3
Const $ADS_NAME_TYPE_NT4 = 3
Const $ADS_NAME_TYPE_1779 = 1


; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 518, 454, 192, 125)
GUICtrlCreateLabel("Username: ", 56, 24, 83, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Inputusername = GUICtrlCreateInput("", 136, 24, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("GO", 296, 24, 65, 25,$BS_DEFPUSHBUTTON )
$ListView1 = GUICtrlCreateListView("Global Groups", 56, 72, 401, 321)
_GUICtrlListViewSetColumnWidth(-1,0,380)

GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($ListView1) ]
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $button1
            $username = ""
            $username = guictrlread($Inputusername)
            if $username == "" Then
                ContinueLoop
            EndIf
            $objRootDSE = ObjGet("LDAP://RootDSE")
            $objTrans = ObjCreate("NameTranslate")
            $objTrans.Init ($ADS_NAME_INITTYPE_GC, "")
        ;$objTrans.Set ($ADS_NAME_TYPE_1779, @LogonDomain)
            $objTrans.Set ($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & $username)
            $strUserDN = $objTrans.Get ($ADS_NAME_TYPE_1779)
            $UserObj = ObjGet("LDAP://" & $strUserDN)
            Listglobalgroups()
    Case $msg = $ListView1
       ; sort the list by the column header clicked on
        _GUICtrlListViewSort($ListView1, $B_DESCENDING, GUICtrlGetState($ListView1))

    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

Func Listglobalgroups()
    
For $oGroup In $UserObj.Memberof
    GUICtrlCreateListViewItem($oGroup,$ListView1)
Next

EndFunc
Posted (edited)

sry but....

YOU CAN'T USE .IsaccountLocked because it is bugged :

link :

http://www.rlmueller.net/LockedUsers.htm

so instead use :

if $objgroup.lockoutTime<>0 then
            if $objgroup.lockoutTime.HighPart<>0 then
                                $userstatus="le compte est bloqué "                
            Else
                $userstatus="Le compte est activé " & @crlf & "Le compte a déjà été vérouillé"
            EndIf
EndIf

c u

@shaun

good way, but too long ...

instead use :

For $oGroup In $UserObj.getex("Memberof")

GUICtrlCreateListViewItem($oGroup,$ListView1)

Next

after play with strings to just have the name ^^ :

$tmp=stringsplit($ogroup,";")

$tmp=stringtrimleft($tmp[1],3)

GUICtrlCreateListViewItem($tmp,$ListView1)

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
  • 8 months later...
Posted

sorry for bumping such a old thread, but i been working on a udpated version of this for my work, and the locked out button does not seem to work, any ideas around how to sort this.

we are on windows 2000

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
×
×
  • Create New...