BakerSyd
asked on
vbs code to detect null entry in active directory and output accordingly
heya
i need a simple IF script that will detect a null entry in the mobile field in active directory
ive looked at isNull and isEmpty but i dont really understand how to get the info from AD
i need the code to do something like this
im not sure if im on the right track here...
im not sure if its meant to be
g_objldapuser has already been specified in a different sub so g_objldapuser.mobile does work if you do a wscript.echo, it will show the correct output.
thanks for your help!
i need a simple IF script that will detect a null entry in the mobile field in active directory
ive looked at isNull and isEmpty but i dont really understand how to get the info from AD
i need the code to do something like this
IF(there is no number in the mobile field) then
do this
Else
do this
end IF
im not sure if im on the right track here...
im not sure if its meant to be
IF IsNull(g_objldapuser.mobile)
then
blah
else
blah
end if
g_objldapuser has already been specified in a different sub so g_objldapuser.mobile does work if you do a wscript.echo, it will show the correct output.
thanks for your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks Chris, i will try this out tomorrow at work and let you know how it goes
cheers!
cheers!
ASKER
Chris, thats working perfectly..
can you explain why you added the Len(Trim(objProperty)) part?
i dont understand this..
can you explain why you added the Len(Trim(objProperty)) part?
i dont understand this..
IsNull (objProperty) tests for Null values
Len(Trim(objProperty)) = 0 tests for empty strings (e.g. "") and strings consisting entirely of whitespace (e.g. " ").
Len() returns the length of a string. e.g. Len("BakerSyd") = 8
Trim() removes any leading and trailing whitespace. e.g. Trim(" BakerSyd ") = "BakerSyd"
Len(Trim(objProperty)) = 0 tests for empty strings (e.g. "") and strings consisting entirely of whitespace (e.g. " ").
Len() returns the length of a string. e.g. Len("BakerSyd") = 8
Trim() removes any leading and trailing whitespace. e.g. Trim(" BakerSyd ") = "BakerSyd"
ASKER
appreciate the explanation and your help
thanks!
thanks!
ASKER
perfect
ASKER
Open in new window
this seems to work... but even thou there is no number in AD it still says "yes number"