WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ADSI Query String Creator


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ADSI Search Builder for WinBatch v1.0a
; Crypt - 2004
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

AddExtender("WWADS34I.DLL")

LDAP="LDAP://"

:Dlg
eq=StrCat("eq",@TAB,"not eq")

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`ADSI Search Builder`
MyDialogX=2001
MyDialogY=2001
MyDialogWidth=212
MyDialogHeight=106
MyDialogNumControls=011
MyDialogProcedure=`DEFAULT`
MyDialogFont=`Arial Narrow|5632|40|34`
MyDialogTextColor=`0|0|0`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`005,051,038,012,PUSHBUTTON,DEFAULT,"Add To Search",1,7,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`099,083,042,012,PUSHBUTTON,DEFAULT,"Exit",0,11,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`005,035,036,012,EDITBOX,name,DEFAULT,DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`045,035,036,066,DROPLISTBOX,eq,"eq",DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog005=`085,035,038,012,EDITBOX,value,DEFAULT,DEFAULT,6,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog006=`003,083,042,012,PUSHBUTTON,DEFAULT,"Test",2,9,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog007=`005,067,200,012,EDITBOX,srchString,DEFAULT,DEFAULT,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog008=`051,083,042,012,PUSHBUTTON,DEFAULT,"Copy to Clipboard",3,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog009=`005,013,136,012,EDITBOX,LDAP,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog010=`007,003,038,008,STATICTEXT,DEFAULT,"Base LDAP Path",DEFAULT,1,DEFAULT,"Arial Narrow|5632|70|34","0|0|0",DEFAULT`
MyDialog011=`007,027,028,008,STATICTEXT,DEFAULT,"Search",DEFAULT,3,DEFAULT,"Arial Narrow|5632|70|34","0|0|0",DEFAULT`

ButtonPushed=Dialog("MyDialog")

If ButtonPushed=="0" Then Exit
If ButtonPushed=="1" Then Goto Build
If ButtonPushed=="2" Then Goto Test
If ButtonPushed=="3" Then ClipPut(srchString)

Goto Dlg

	:Build
	If eq=="eq" Then eq="(&"
	If eq=="not eq" Then eq="(!"
	If SrchString==""
		srch1=Strcat(eq,"(",Name,"=",Value,")")
	Else
		Counta=ItemCount(srchString,"=")
		For x = 1 to Counta-1 
			SrchString=ItemRemove(-1,SrchString,")")
		Next

		srch1=Strcat(SrchString,eq,"(",Name,"=",Value,")")
		SrchString=StrCat("(",srchString,srch1,")")
	EndIf
		srchString=StrCat(srch1)
		Count=ItemCount(srchString,"=")
		For x = 1 to Count-1 
			SrchString=StrCat(SrchString,")")
		Next
		
	Goto Dlg

:Test
	if srchString != ""
		Result=DsFindPath(LDAP,srchString)
		ResultCount=ItemCount(Result,@TAB)
		Message("%ResultCount% Results",Result)
	else
			Message("ADSI Search Builder","Search string must have a value")
	endif
	Goto Dlg

Article ID:   W16329
File Created: 2005:02:18:12:19:48
Last Updated: 2005:02:18:12:19:48