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
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
--