Page 1 of 2 12>
Topic Options
#86017 - 2002-06-13 04:19 PM $object.Filter Issue
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Ok Shawn, I need some help. Since you didn't like the Perl version, I translated it into something you can read, but the program dies when the a filter is applied. What maistake did I make.

code:
break on

EnumOUsForComputers("LDAP://us-tyco-e/OU=NCS, OU=Machines, DC=us,DC=tycoelectronics, DC=com", "computer");

Function EnumOUsForComputers($LDAP, $Filter)
;$Filter = 'computer' | 'user'
dim $pos
$objOU = GetObject($LDAP);
"LDAP string='$LDAP'" ? ?
if VarTypeName($objOU)='Object'
$objOU.Filter = $Filter,""
for each $item in $objOU
$Name = $item.get("Name")
"@error @Serror $Name"
substr($Name,4,instr($Name,"/")-1) ?
next
$objOU.Filter = "organizationalUnit",""
"@error @serror"
for each $item in $objOU
? "In OU loop"
$pos = instr($LDAP,OU=)
$DN = Left($LDAP,$pos-1) + $Name + ", " + substr($LDAP, $pos)
? $DN
EnumOUsForComputers($DN);
next
else
"GetObject COM error: " + @error + " " + @serror
endif
Endfunction



[ 13 June 2002, 16:20: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#86018 - 2002-06-13 04:25 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Your asking the OLE Fart ?

Filter has to be an array, yeah ?

$Filter = 'computer','user'

But I sense your trying to do something tricky here, whats up ?

Top
#86019 - 2002-06-13 04:30 PM Re: $object.Filter Issue
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Look closer. It is an array; isn't it?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#86020 - 2002-06-13 04:32 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Yeah, saw that. But what does this resolve to ?

$Filter = 'computer' | 'user'

Anything meaningfull to ADSI ?

Top
#86021 - 2002-06-13 04:33 PM Re: $object.Filter Issue
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
It's a comment describing the valid values.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#86022 - 2002-06-13 04:36 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
oops - wait a sec - im with you know - 1 sec ...
Top
#86023 - 2002-06-13 04:43 PM Re: $object.Filter Issue
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
But the line EnumOUsForComputers("LDAP://u.. doesn't contain a filter, but just a string ? I thought $filter should be an array ??

I'm totally not into OLE, so don't shoot me [Wink]
_________________________
Kind regards,

Top
#86024 - 2002-06-13 04:48 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
What COM error are you getting Howard, don't forget, the timeout on ADSI is painfully long. And if your running against defunct machine accounts ... zzz ...
Top
#86025 - 2002-06-13 04:48 PM Re: $object.Filter Issue
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
After using getObject on $LDAP, I:

$objOU.Filter = $Filter,"" using the text in $Filter.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#86026 - 2002-06-13 04:50 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
see above, I usually do a PING to the machine first, before trying to issue cache gets ...
Top
#86027 - 2002-06-13 04:55 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Try using just the cached name, eg:

$Name = $item.name
"@error @Serror $Name"
substr($Name,4,instr($Name,"/")-1) ?

You will see a big difference, me thinx

Top
#86028 - 2002-06-13 05:27 PM Re: $object.Filter Issue
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I am performing a GetObject on a known OU in AD and do not ever get from a "computer".

Let's just work with the OU loop.

If I comment out the filter I get output. When I use the Filter the script dies. I should be able to enumerate the OU hierarchy with this code.

code:
break on

EnumOUsForComputers("LDAP://us-tyco-e/OU=NCS, OU=Machines, DC=us, DC=tycoelectronics, DC=com", "computer");

Function EnumOUsForComputers($LDAP, $Filter)
;$Filter = 'computer' | 'user'
dim $pos
$objOU = GetObject($LDAP);
"LDAP string='$LDAP'" ? ?
if VarTypeName($objOU)='Object'
; $objOU.Filter = $Filter,""
; for each $item in $objOU
; $Name = $item.Name
; "@error $Name " + $objOU.class ?
; substr($Name,4,instr($Name,"/")-1) ?
; next
;$objOU.Filter = "organizationalUnit",""
for each $item in $objOU
$Name = $item.Name
$pos = instr($LDAP,"OU=")
$DN = Left($LDAP,$pos-1) + $Name + ", " + substr($LDAP, $pos)
EnumOUsForComputers($DN, $Filter);
next
else
"GetObject COM error: " + @error + " " + @serror
endif
Endfunction




[ 13 June 2002, 17:55: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#86029 - 2002-06-13 05:56 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Howard, just playing with things here, but its
hard to replicate your problem because I don,t
have AD here ...

one thing I noticed though, and this goes back
to the importance of dimming UDF vars, since
this routine is recursive, shouldn't you be
dimming your $objou var ? - because your second
iteration might clobber your first iterations
object ?

[ 13 June 2002, 17:57: Message edited by: Shawn ]

Top
#86030 - 2002-06-13 06:03 PM Re: $object.Filter Issue
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Yes you are right - I should be -> and now I am and still no joy. Same old crap.

I known I have a valid object to start with:

quote:
c:\data\scripts>C:\Data\Kix2001\KiX2001.410rc2\kix32 enumOus.kix
LDAP string='LDAP://us-tyco-e/OU=NCS, OU=Machines, DC=us, DC=tycoelectronics, DC=com'

Class: organizationalUnit
GUID: {228D9A87-C302-11CF-9AA4-00AA004A5691}
Implemented by: {228D9A8C-C302-11CF-9AA4-00AA004A5691}

Container Object
Class Contains:
remoteMailRecipient
msExchConfigurationContainer
container
intellimirrorGroup
organizationalUnit
indexServerCatalog
computer
locality
ipsecNFA
applicationEntity
ipsecISAKMPPolicy
serviceAdministrationPoint
contact
intellimirrorSCP
mS-SQL-OLAPServer
mSMQMigratedUser
physicalLocation
remoteStorageServicePoint
volume
mS-SQL-SQLServer
group
rRASAdministrationConnectionPoint
user
nTFRSSettings
serviceConnectionPoint
ipsecNegotiationPolicy
dSA
dMD
rpcContainer
domainPolicy
ipsecPolicy
ipsecFilter
groupPolicyContainer
printQueue
classStore
Mandatory Properties in this Class:
instanceType
nTSecurityDescriptor
objectCategory
objectClass
ou

Optional Properties in this Class:
adminDescription
adminDisplayName
allowedAttributes
allowedAttributesEffective
allowedChildClasses
allowedChildClassesEffective
bridgeheadServerListBL
businessCategory
c
canonicalName
cn
co
countryCode
createTimeStamp
defaultGroup
description
desktopProfile
destinationIndicator
directReports
displayName
displayNamePrintable
distinguishedName
dSASignature
dSCorePropagationData
extensionName
facsimileTelephoneNumber
flags
fromEntry
frsComputerReferenceBL
fRSMemberReferenceBL
fSMORoleOwner
gPLink
gPOptions
internationalISDNNumber
isCriticalSystemObject
isDeleted
isPrivilegeHolder
l
lastKnownParent
managedBy
managedObjects
masteredBy
memberOf
modifyTimeStamp
mS-DS-ConsistencyChildCount
mS-DS-ConsistencyGuid
name
netbootSCPBL
nonSecurityMemberBL
objectGUID
objectVersion
otherWellKnownObjects
partialAttributeDeletionList
partialAttributeSet
physicalDeliveryOfficeName
possibleInferiors
postalAddress
postalCode
postOfficeBox
preferredDeliveryMethod
proxiedObjectName
proxyAddresses
queryPolicyBL
registeredAddress
replPropertyMetaData
replUpToDateVector
repsFrom
repsTo
revision
sDRightsEffective
searchGuide
seeAlso
serverReferenceBL
showInAdvancedViewOnly
siteObjectBL
st
street
subRefs
subSchemaSubEntry
systemFlags
telephoneNumber
teletexTerminalIdentifier
telexNumber
thumbnailLogo
uPNSuffixes
url
userPassword
uSNChanged
uSNCreated
uSNDSALastObjRemoved
USNIntersite
uSNLastObjRem
uSNSource
wbemPath
wellKnownObjects
whenChanged
whenCreated
wWWHomePage
x121Address

c:\data\scripts>

I know that with the filter commented out that the script does properly enumerate the objects in the container. It enumerates bother computers and other OUs.

But when the Filter is applied the script dies.

Shawn when are you going to setup an AD domain? We need to deligate our troubleshooting expenses to you. [Big Grin]

[ 13 June 2002, 18:12: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#86031 - 2002-06-13 06:05 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Plus, when you remove the filter, you said you
get output, are successfully recursing and
getting lots of output - or just a bit ?

Just as a test, what happens if you remove the
filter and just programatically check for
$objou.class = "organizational unit" ?

Are you thinking the the filter is broke ?

Top
#86032 - 2002-06-13 06:12 PM Re: $object.Filter Issue
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I think that the filter is broken when applied to OU objects (at least) since it seems to work other places.

I get tons of output - thousands on objects without the filter.

If I manually filter:
code:
   $objOU = GetObject($LDAP);
if $objou.class <> "organizationalunit" exit 0 endif

I only get OU's and no computers.
Can someone with AD please try to verify this issue?

[ 13 June 2002, 18:13: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#86033 - 2002-06-13 06:16 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Think I know what it is ... standby ...

Yeah, maybe ...

We always created filters like this becuase it was convient:

$filter = "user",""

and the WinNT provider was never sensitive to the fact the the second element of the array was a NULL string ... now, your using the LDAP provider which may have more stringient rules about this, so I would suggest you handjob the array instead, example:

dim $filter[0]

$filter[0] = "organizationalUnit"

Crossing my fingers ...

-Shawn

[ 13 June 2002, 18:23: Message edited by: Shawn ]

Top
#86034 - 2002-06-13 06:21 PM Re: $object.Filter Issue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
When I used the filter, I explicitly created an array for the filter variable and it worked.
code:
Dim $filtervars[0]
$filtervars[0]='test'
$object.filter=$filtervars

The ADSI/WMI documentation even says something about requiring an array as input.

[ 13 June 2002, 18:21: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#86035 - 2002-06-13 07:00 PM Re: $object.Filter Issue
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Howie ? Did you fall off your chair ?
Top
#86036 - 2002-06-13 07:20 PM Re: $object.Filter Issue
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
naa... probably playing with RC cars in the parking lot
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.067 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

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