From: Dan on
I am trying to determine the best way to write a snippet that determines if
an Active Directory contact already exists. My current script looks at users
and creates contact objects for them. The trouble I have is obviously
running the script a second time bombs me out with "object already exists".
What I'm look ing for would be:

If contact exists then....
Else.....

Anyone got a good starting point for me? Lots of stuff online for 'if file
exists...' but it seems not many are creating contacts.

From: LikeToCode on
Hi Dan,
You could use the Instr Function to compare your contact name with the AD
object name. Something like:

If Instr(strContactName,objUser.name) = 0 Then 'Contact DOES NOT Exist
'Do Something
Else
'Your contact exists
End If
From: "Steven Cheng" on
Hi Dan,

Seems you're using ADSI script to detecting AD/exchange contacts in certain
directory path. For AD user or contract objects, you can use script to
enumerate them:

#Scripting Exchange Using VBScript and ADSI (Part 1)
http://palladium2/MyManagedThreads.aspx

for your case that you want to check whether a contact already exists, it
it possible that you first enumerate and save all the existing objects(by
their name) into an array in code and then loop through the array instead
of the AD object for comparing?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg(a)microsoft.com.



--------------------
>From: =?Utf-8?B?RGFu?= <Dan(a)discussions.microsoft.com>
>Subject: How to tell if a contact object exists?
>Date: Mon, 8 Mar 2010 14:10:01 -0800

>
>I am trying to determine the best way to write a snippet that determines
if
>an Active Directory contact already exists. My current script looks at
users
>and creates contact objects for them. The trouble I have is obviously
>running the script a second time bombs me out with "object already
exists".
>What I'm look ing for would be:
>
>If contact exists then....
>Else.....
>
>Anyone got a good starting point for me? Lots of stuff online for 'if
file
>exists...' but it seems not many are creating contacts.
>
>