Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBScript AD recordset check Attribute Value is not set

381 views
Skip to first unread message

Yas

unread,
Sep 16, 2007, 5:26:03 PM9/16/07
to
Hello, I have a ADO recordset after connecting to Active directory
with couple of 100 users.

I am trying to filter out users with certain attributes missing/not-
set...eg extensionAttribute1 and 2.... But I don't know how to check
or catch the missing attributes... I have tried with IsNull to catch
the "not set" attribute and also attrib = "" as well as attrib = " "
in case they return blanks but none works.

So basically how can I check and find users that dont have a certain
attribute set?

eg

Do While IsNull(adoADRecordset.Fields("extensionAttribute1").Value) OR
_
(adoADRecordset.Fields("extensionAttribute1").Value = "")

adoADRecordset.MoveNext

Loop


Many thanks :-)

Yas

Richard Mueller [MVP]

unread,
Sep 16, 2007, 8:21:44 PM9/16/07
to
Yas wrote:

You can use IsNull, or you can append a blank string to the value and test
for the blank string. For example:

If (IsNull(adoRecordset.Fields("extensionAttribute1").Value) = False) Then
' Do something.
End If

or

If (adoRecordset.Fields("extensionAttribute1").Value & "" = "") Then
' Do something.
End If

The clause:

(adoADRecordset.Fields("extensionAttribute1").Value = "")

will never be True and will raise an error when the value is Null.

Also, you can use a filter that only returns records where the attribute has
a value (or does not have a value). For example to retrieve records for all
users that have a value assigned to extensionAttribute1, use the filter:

(&(objectCategory=person)(objectClass=user)(extensionAttribute1=*))

To retrieve records for all users that do not have a value assigned, use the
filter:

(&(objectCategory=person)(objectClass=user)(!extensionAttribute1=*))

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


0 new messages