Mombu the Microsoft Forum

Go Back   Mombu the Microsoft Forum > Microsoft > VBScript AD recordset check Attribute Value is not set
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 30th October 05:51
yas
External User
 
Posts: 1
Default VBScript AD recordset check Attribute Value is not set



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").Valu e = "")

adoADRecordset.MoveNext

Loop


Many thanks :-)

Yas
  Reply With Quote


 


2 30th October 05:52
richard mueller [mvp]
External User
 
Posts: 1
Default VBScript AD recordset check Attribute Value is not set



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").Valu e = "")

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)(extens ionAttribute1=*))

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

(&(objectCategory=person)(objectClass=user)(!exten sionAttribute1=*))

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


Thread Tools
Display Modes




666