1

I have an exchange server 2010 running, and want to programmatically add contacts into the server. What is the way to achive this?

Best to be done in Java, but VB6 would be okay, too.

Daniel
  • 844
  • 7
  • 24

1 Answers1

1

When you say "add contacts into the server", what exactly do you mean?

Exchange doesn't contain contacts itself. You can add contacts to active directory to be visible in the global address book for all exchange users. There's sample code to do this here.

Alternatively you can add contacts to an individual user's contacts in outlook, which will make them available to that individual user - you can of course run this script for several users if you want to make the contacts available to more than one person. Not tested this one, but there's sample code available here to get you started.

If you go with the first route and have a large number of contacts to add then you may end up with a Global Address List (GAL) that is very large and difficult to use, and the unpleasant prospect of emails intended for internal use only sent to external people who are in your contacts list. It's possible to prevent this by creating more than one view of the GAL - one that includes contacts and one that only includes Windows accounts (aka 'full' exchange users).

You can use the Exchange Management Shell to manipulate the GAL as follows (example from technet forums)

Get-GlobalAddressList "Default Global Address List" |FL *Filter

you will see a filter like:

{(Alias -ne $null -and (ObjectClass -eq 'user' -or ObjectClass -eq 'contact' -or ObjectClass -eq 'msExchSystemMailbox' -or ObjectClass -eq 'msExchDynamicDistributionList' -or ObjectClass -eq 'group' -or ObjectClass -eq 'publicFolder'))}

I've highlighted where the default GAL's filter includes contact objects too, because of the condition ObjectClass -eq 'contact'.

So if you want that your default GAL exclude these contacts object then you will have to reset the Recipient Filter of your GAL like this:

Set-GlobalAddressList "Default Global Address List" -RecipientFilter {(Alias -ne $null -and (ObjectClass -eq 'user' -or ObjectClass -eq 'msExchSystemMailbox' -or ObjectClass -eq 'msExchDynamicDistributionList' -or ObjectClass -eq 'group' -or ObjectClass -eq 'publicFolder'))}

and then you can create some other GAL for the contacts similar to this:

New-GlobalAddressList "Contacts Global Address List" -RecipientFilter {(Alias -ne $null -and ObjectClass -eq 'Contact')}

As I work at a college, we've played about with examples similar to the above ones to control what students can and cannot see in the GAL, so I know the principles work, you'll just need to fiddle and test the filters until you get a result you're happy with. We're using Exchange 2007 but for things like this there shouldn't be any significant differences.

Rob Moir
  • 31,884
  • 6
  • 58
  • 89
  • +1 this is good answer, IMHO, because it tells me that I simply have to sync with the AD and push our contact information there. Btw, do you know about the behaviour of Exchange if it contains 25000 contacts? :) – Daniel Feb 04 '11 at 09:26
  • @Daniel 25000 contacts is a bit rich for my blood, but I think Microsoft have whitepapers where they've done things like that (come to that, wouldn't their own internal address book or that of their big customers come close?) – Rob Moir Feb 04 '11 at 09:31
  • I just wondered if it would be feasible for large corporations to sync our ERP address book with their Exchange Server. But for all smaller companies with a few hundred contacts I would see no problems. – Daniel Feb 04 '11 at 10:09
  • @Daniel - in that case you can create two views of the global address book, one that excludes contacts so its just your internal employees as normal, and another view for the contacts you have added. I'll edit my answer to add notes and links for this. – Rob Moir Feb 04 '11 at 10:30
  • +1 great info! This allows for me to spit between supplier and customer contacts (and prospectives)! – Daniel Feb 04 '11 at 11:02
  • I just created a contact in an Exchange Server public contact folder, but I can't seem to find it in my LDAP browser, when connecting to the Exchange server. Are you sure all contacts in Exchange are stored in the AD? – Daniel Feb 04 '11 at 11:40
  • Ahh... I'm certain that Exchange stores its contact and user info in AD (see http://technet.microsoft.com/en-us/library/aa998858.aspx). Are you using public folders? Those are datastores and their contents are held in the info store rather than AD (&are just a bunch of data to exchange). I'm talking about contacts created in exchange itself via *recipient configuration/Mail Contacts* in the console or *new-MailContact* in powershell. Public Folders are deprecated in Exchange, I believe, so I wouldn't suggest using them to store contacts. – Rob Moir Feb 04 '11 at 11:57
  • I can't believe that public folders are deprecated for contacts, because those contacts hold much more information (incl. a picture e.g.) than the entries in the AD. At least if managed by the EMC, as desdribed in the link from you. Using the AD is a solution, and one I will use, if there are no other possibilities, but accessing the info store will be much more fun. – Daniel Feb 04 '11 at 17:13
  • @Daniel - public folders in Exchange were deprecated with the release of Exchange 2007. Microsoft still support their use but are essentially phasing them out sooner or later. I suspect they'd rather people used sharepoint. I don't know if they'll go away completely in the next version of Exchange but I wouldn't be surprised, so I'd personally hesitate to use them in any new deployment of Exchange at the moment (see http://msexchangeteam.com/archive/2008/03/31/448537.aspx) – Rob Moir Feb 04 '11 at 18:06
  • I just googled it, and here (http://msexchangeteam.com/archive/2006/02/20/419994.aspx) they say, that at least Exchange 2012 will still contain public folders, and support is ongoing till 2016 at least. Of course they want us to use sharepoint, but since nearly none of our customers use this, I will go with public folders. – Daniel Feb 04 '11 at 19:32
  • @Daniel - I used to work with the Exchange people at Microsoft. When they talk about "Exchange 12" they mean "Version 12 of Exchange Server" which translates to "Exchange 2007", not "Exchange 2012" (the big jump in version numbers was to align the Exchange version numbers with Office version numbers to make release schedules clearer). I should apologise if it sounds like I'm being pushy: I'm not trying to tell you what to use, I understand the preference for public folders completely, just that you need to keep their potentially short lifespan in mind. – Rob Moir Feb 04 '11 at 19:39