views:

3061

answers:

4

We need to remotely create an Exchange 2007 distribution list from Asp.Net.

Near as I can tell, the only way to create a distribution list in the GAL is via the exchange management tools. Without installing this on our web server, is there any way to create a distribution list remotely? There are some third party components that allow you to create personal distribution lists, but these only live in a users Contacts folder and are not available to all users within the company.

Ideally there would be some kind of web services call to exchange or an API we could work with. The Exchange SDK provides the ability to managing Exchange data (e.g. emails, contacts, calendars etc.). There doesn't appear to be an Exchange management API.

It looks like the distribution lists are stored in AD as group objects with a special Exchange attributes, but there doesn't seem to be any documentation on how they are supposed to work.

Edit: We could reverse engineer what Exchange is doing with AD, but my concern is that with the next service pack of Exchange this will all break.

Is there an API that I can use to manage the distribution lists in Active Directory without going through Exchange?

A: 

Look for LDAP.NET, I don't have it handy but I've done it before and it worked well at the time.

Edit: I should add that LDAP is Lightweight Directory Access Protocol.

Also, I can't find LDAP.NET (I got curious and went to look) and now it appears that there's a built-in System.DirectoryServices namespace to do it for you.

http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/729d1214-37f5-4330-9208-bc4d9d695ad0

Mark Allen
I'm aware of LDAP and other AD apis, but there isn't much documentation on how Exchange uses AD. We could reverse engineer what Exchange is doing, but without documentation I'm concerned that our code would break with the next Exchange service pack.
Darren
A: 

@Darren's comment, since I cannot comment yet: It's just LDAP - Exchange may (and does) extend the Schema, but other than possibly having to adjust what fields you set in the future when you create or update a group, you're fine.

(I'm a former tech support person who supported Exchange including AD, so I'm not guessing here.)

Mark Allen
+1  A: 

Thanks Mark -- we've gone ahead and created a new list using AD and it seems to be working (this is the equivalent of 'new-DistributionGroup' in powershell).

However, there is another step that is required -- 'enable-DistributionGroup' in PowerShell that seems to do some Exchange magic that actually allows the DG to receive email. This doesn't appear to be an AD setting, but we could be looking in the wrong place.

Do you know of any way to set the DG as enabled via AD?

Darren
+1  A: 

We had a similar problem with mail enabling programatically created public folders and needed to set the msExchHideFromAddressLists property on the exchange system object in active directory...

using (DirectoryEntry LDAPConnection = new DirectoryEntry("LDAP://OURDOMAIN/CN=" + name+ ",CN=Microsoft Exchange System Objects,DC=ourdomain,DC=com"))
{
    LDAPConnection.AuthenticationType = AuthenticationTypes.Secure;
    LDAPConnection.Properties["msExchHideFromAddressLists"].Value = false;
    LDAPConnection.CommitChanges();
}

PS. make sure that any DirectoryEntries are properly disposed of or you'll likely run out of connections before the GC kicks in and end up having to restart the server to clear them.

ballpointpeon