Hi, is there a way to check if an attribute of a user object in Active
Directory is "Not Set", i.e. currently has no values set?

Checking for Null or an empty string doesn't seem to be possible, but I
don't really want to rely on checking for an error.

many thanks,
Craig

Re: Check if AD attribute exists by J

J
Thu Jun 14 11:25:34 CDT 2007

checking for empty strings is perfectly possible. do it all the time.
howzabout posting the code that is failing?



"Craig" <craig@somerubbish.com> wrote in message
news:%23VQUuLorHHA.5032@TK2MSFTNGP04.phx.gbl...
> Hi, is there a way to check if an attribute of a user object in Active
> Directory is "Not Set", i.e. currently has no values set?
>
> Checking for Null or an empty string doesn't seem to be possible, but I
> don't really want to rely on checking for an error.
>
> many thanks,
> Craig


Re: Check if AD attribute exists by Richard

Richard
Thu Jun 14 11:38:09 CDT 2007

Also, you can use ADO to query AD for objects where either an attribute has
a value, or where the attribute is missing. For example:

(&(sAMAccountName=JimSmith)(employeeID=*))

will only return a record if user JimSmith has a value assigned to
employeeID. Otherwise, no records are returned. Or:

(&(sAMAccountName=JimSmith)(!employeeID=*))

will only return a record if user JimSmith does not have a value assigned to
the employeeID attribute. The RecordCount property of the Recordset object
can be used to check whether 0 or 1 record was retrieved. And, these queries
can be used in ADUC to filter objects in the display. You could filter for
all users that do not have a value assigned to employeeID with:

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

For more on using ADO to search AD, see this link:

http://www.rlmueller.net/ADOSearchTips.htm

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

"J. Anos" <j@anos.com> wrote in message
news:etIqyBqrHHA.5032@TK2MSFTNGP04.phx.gbl...
> checking for empty strings is perfectly possible. do it all the time.
> howzabout posting the code that is failing?
>
>
>
> "Craig" <craig@somerubbish.com> wrote in message
> news:%23VQUuLorHHA.5032@TK2MSFTNGP04.phx.gbl...
>> Hi, is there a way to check if an attribute of a user object in Active
>> Directory is "Not Set", i.e. currently has no values set?
>>
>> Checking for Null or an empty string doesn't seem to be possible, but I
>> don't really want to rely on checking for an error.
>>
>> many thanks,
>> Craig
>



Re: Check if AD attribute exists by Craig

Craig
Thu Jun 14 13:28:12 CDT 2007

the below produces a type mismatch error. have I got the syntax wrong?

if not objUser.carLicense="" then
loop through the values
end if





J. Anos wrote:
> checking for empty strings is perfectly possible. do it all the time.
> howzabout posting the code that is failing?
>
>
>
> "Craig" <craig@somerubbish.com> wrote in message
> news:%23VQUuLorHHA.5032@TK2MSFTNGP04.phx.gbl...
>> Hi, is there a way to check if an attribute of a user object in Active
>> Directory is "Not Set", i.e. currently has no values set?
>>
>> Checking for Null or an empty string doesn't seem to be possible, but
>> I don't really want to rely on checking for an error.
>>
>> many thanks,
>> Craig
>

Re: Check if AD attribute exists by Richard

Richard
Thu Jun 14 13:44:16 CDT 2007

When an attribute is not assigned a value, the value is neither blank nor
Null. You can use IsEmpty to check. For example:

If Not IsEmpty(objUser.carLicense) Then
' Loop.
End If

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

"Craig" <craig@somerubbish.com> wrote in message
news:eMkGIHrrHHA.1268@TK2MSFTNGP03.phx.gbl...
> the below produces a type mismatch error. have I got the syntax wrong?
>
> if not objUser.carLicense="" then
> loop through the values
> end if
>
>
>
>
>
> J. Anos wrote:
>> checking for empty strings is perfectly possible. do it all the time.
>> howzabout posting the code that is failing?
>>
>>
>>
>> "Craig" <craig@somerubbish.com> wrote in message
>> news:%23VQUuLorHHA.5032@TK2MSFTNGP04.phx.gbl...
>>> Hi, is there a way to check if an attribute of a user object in Active
>>> Directory is "Not Set", i.e. currently has no values set?
>>>
>>> Checking for Null or an empty string doesn't seem to be possible, but I
>>> don't really want to rely on checking for an error.
>>>
>>> many thanks,
>>> Craig
>>



Re: Check if AD attribute exists by Craig

Craig
Thu Jun 14 14:01:35 CDT 2007

This is exactly what I've been looking for. Works a treat!

Many thanks Richard.




Richard Mueller [MVP] wrote:
> When an attribute is not assigned a value, the value is neither blank nor
> Null. You can use IsEmpty to check. For example:
>
> If Not IsEmpty(objUser.carLicense) Then
> ' Loop.
> End If
>