Jump to content
Sign in to follow this  
CodeDeep

ldapsearch

Recommended Posts

CodeDeep

I created a small GUI with the intent to search an eDirectory LDAP tree. Here's all I want from it:

text box to put in userid

text box to put in last name

search button

based on the 2 text boxes, a local executable will be kicked off to reference these 2 entries and search ldap. It then give me the results of what it find.

I'm SOOOOO new to AUTOIT, has anyone ever heard of something like this?

Share this post


Link to post
Share on other sites
Lars

You can use COM objects and do LDAP queries, I am doing this all the time.

Look at my example

CODE
Func ldapQuery($myQuery, $scope = 0)

$objConnection = ObjCreate("ADODB.Connection")

$objCommand = ObjCreate("ADODB.Command")

$objConnection.Provider = "ADsDSOObject"

$objConnection.Open ("Active Directory Provider")

$objCommand.ActiveConnection = $objConnection

$objCommand.CommandText = $myQuery

$objCommand.Properties("Page Size") = 1000

If $scope > 0 Then

$objCommand.Properties("Searchscope") = $scope

Else

$objCommand.Properties("Searchscope") = $ADS_SCOPE_SUBTREE

EndIf

$objRecordSet = $objCommand.Execute

$objRecordSet.MoveFirst

Return $objRecordSet

EndFunc

Share this post


Link to post
Share on other sites
CodeDeep

Thanks, Like I said though, I literally know nothing about this language. here's what I got... (does nothing yet)

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\documents and settings\plummb\desktop\_1.kxf

$_1 = GUICreate("Find User CN", 342, 165, 192, 125)

$cn = GUICtrlCreateEdit("", 126, 32, 185, 17, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))

GUICtrlSetData(-1, "")

$Search = GUICtrlCreateButton("Search", 126, 130, 50, 20, $WS_GROUP)

$ExitID = GUICtrlCreateButton("Exit", 262, 130, 50, 20, $WS_GROUP)

$givenName = GUICtrlCreateEdit("", 126, 88, 185, 17, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))

GUICtrlSetData(-1, "")

$UIDEntry = GUICtrlCreateLabel("User ID:", 120, 15, 43, 17)

$LNEntry = GUICtrlCreateLabel("Last Name:", 120, 70, 58, 17)

$Penguin = GUICtrlCreatePic("\\oden\dist\applications\Xtras\Images\penguin.jpg", 8, 16, 100, 116, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

You can use COM objects and do LDAP queries, I am doing this all the time.

Look at my example

CODE
Func ldapQuery($myQuery, $scope = 0)

$objConnection = ObjCreate("ADODB.Connection")

$objCommand = ObjCreate("ADODB.Command")

$objConnection.Provider = "ADsDSOObject"

$objConnection.Open ("Active Directory Provider")

$objCommand.ActiveConnection = $objConnection

$objCommand.CommandText = $myQuery

$objCommand.Properties("Page Size") = 1000

If $scope > 0 Then

$objCommand.Properties("Searchscope") = $scope

Else

$objCommand.Properties("Searchscope") = $ADS_SCOPE_SUBTREE

EndIf

$objRecordSet = $objCommand.Execute

$objRecordSet.MoveFirst

Return $objRecordSet

EndFunc

Share this post


Link to post
Share on other sites
Lars

Hmmz,

You still got a lot to do I see and I am kind'a buzy at the moment so I am not gonna write your code.

AutoIt is as easy as vbscript and if you know some languages it's not so hard to find out.

Variables are not type specific so it can be a string or integer or be changed on the fly depending on what you

do with it

so if $i = 1 and you increment it with 1 it will be 2. If you add "lol" to it, it will be 1lol.

With the code example above you can query LDAP, it returns a recordset you can loop trough.

All about looping, if else cases and stuff can be found in the totally awsome help file. ( Wish they had a helpfile on women like the autoit one :D )

So lots of luck with your tool.

Share this post


Link to post
Share on other sites
CodeDeep

thank you! I will hash it out. Gotta start somewhere!

Hmmz,

You still got a lot to do I see and I am kind'a buzy at the moment so I am not gonna write your code.

AutoIt is as easy as vbscript and if you know some languages it's not so hard to find out.

Variables are not type specific so it can be a string or integer or be changed on the fly depending on what you

do with it

so if $i = 1 and you increment it with 1 it will be 2. If you add "lol" to it, it will be 1lol.

With the code example above you can query LDAP, it returns a recordset you can loop trough.

All about looping, if else cases and stuff can be found in the totally awsome help file. ( Wish they had a helpfile on women like the autoit one :D )

So lots of luck with your tool.

Share this post


Link to post
Share on other sites
Lars

Stop sleeping for 2 nights, order some pizza and tell your colleguas you're dead.

And in 1 or 2 day's you'll have the autoIt revelation :D

suc6

Share this post


Link to post
Share on other sites
CodeDeep

Is that all it takes? Count me in!

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  

×