Page 1 of 1 1
Topic Options
#90271 - 2002-12-04 03:31 PM ADSI .filter doesn't work
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
I am unable to utilize the filter method when working with ADSI objects. I'm not sure if this is a KiX limitation or if the syntax is slightly different then from VB. Here's how it works in VB (and I've looked at dozens of script to make sure this is the absolute correct way)...
code:
Set NTDomain = GetObject("WinNT://YourDomainName")
NTDomain.Filter = Array("User")
userlist = "User List: " & vbCrLf
for each usr in NTDomain
userlist = userlist & usr.name & vbCrLf
next

This code prevents groups and computers from being returned when all items are enumerated. However, when I try to use the .filter method in a KiX script it never filters anything. I don't get an error, and I can even use really bad syntax and it still won't return an error. This is leading me to believe that for whatever reason KiX is not supporting the .filter method. Here's some code I am trying to use...
code:
BREAK ON
$adsDomain = GetObject("WinNT://@LDOMAIN,Domain")
$adsDomain.Filter = Array("User")
FOR EACH $ELEMENT IN $adsDomain
? $ELEMENT.NAME + " : " + $ELEMENT.CLASS
NEXT
$adsDomain = Nothing

Anyone have any insight on this?

-Ben
http://www.rgcweb.org/kix

Top
#90272 - 2002-12-04 03:33 PM Re: ADSI .filter doesn't work
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Yeah, the syntax is different in KiX. Try...

code:
$adsDomain.Filter = "User",""


Top
#90273 - 2002-12-04 03:35 PM Re: ADSI .filter doesn't work
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
BTW, KiX has no function called Array(). [Wink]
Top
#90274 - 2002-12-04 03:41 PM Re: ADSI .filter doesn't work
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
I have to admit that Lonkero's BBChecker could be the best thing to happen to this board (other then KiX and KiXForms of course [Smile] ). These responses come in so fast.

Thanks for the correction Chris. It works fine now. I didn't think Array() would work, but I tried "User" and User and "resU" and couldn't get anywhere. I'll now be able to add the filter back into my User Manager tool and it should help speed things up for people with lots of objects in their AD.

-Ben
http://www.rgcweb.org/kix

Top
#90275 - 2002-12-04 03:44 PM Re: ADSI .filter doesn't work
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Note that:

$adsDomain.Filter = "User",""

Only works for the WinNT:// provider.

You have to make an array for the LDAP:// provider.

Dim $Array[0]
$Array[0] = "User"
$adsDomain.Filter = $Array

[ 04. December 2002, 15:44: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#90276 - 2002-12-04 03:46 PM Re: ADSI .filter doesn't work
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Did not know that. I'll file that for future reference (if we ever get AD here [Roll Eyes] ). Thanks, Howard.
Top
#90277 - 2002-12-04 10:56 PM Re: ADSI .filter doesn't work
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11589
Loc: CA
Howard is correct, but I'm fairly sure that kix will take ARRAY without the other arguments.

I've converted some VB scripts before without using all the "correct" KiX syntax and the code did work.

I'll have to look around and see if I can find that one. It was about 6 months or so ago now.

Top
#90278 - 2002-12-04 11:57 PM Re: ADSI .filter doesn't work
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Well, it will even accept...
code:
$adsDomain.Filter = EveryGoodBoyDoesFine()

...and not burp, but the filter won't actually filter anything out.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 138 anonymous users online.
Newest Members
eltonfaturetto, janvda, OBIns, kookken, larisa
17706 Registered Users

Generated in 0.032 seconds in which 0.012 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org