Tuesday 21 October 2014

Forcibly Removing a Public Folder's SMTP Address from Exchange 2010 SP3

After a massive Exchange outage ending in the server being rebuild I was asked why a user was no longer seeing e-mails from the info@domain.com UK address. At the time I was not sure if address was a mailbox, a secondary SMTP address for a user or even a mail-enabled public folder.

I used the following PowerShell command to see if the info@ address belonged to a mailbox and/or user.

Get-Mailbox –an info


It returned no results, so I searched the domain to find where the SMTP address resided within Active Directory, this can be done using the Active Directory Users and Computers MMC, using Find and a Custom Search. You will notice that info@ belongs to a mail-enabled Public Folder.

I used the following command to determine the state of the Public Folders, I knew as I had just rebuild and restored the Mailbox Databases that the Public Folder databases had not been restored.
Get-PublicFolder info

As expected PowerShell returned the error "Couldn't find an available public folder database. Make sure that there is a public folder database on at least one server". I consulted with the customer and they decided that the content in the info@ Public Folder was mostly junk and could be forgotten about.

The next step was to remove the failed Public Folder database from ADSI Edit, as the Domain Controller I had access to was Windows Server 2003 R2 I had to manually add the ADSI Edit snap-in from a custom MMC. Ensure you change the Naming Content to Configuration and click OK.

Expand Configuration\CN=Services\CN=Microsoft Exchange\CN=DOMAIN\CN=Administrative Group (FYxx)\CN=Databases right click on the CN=Public Folder DB Name and select Delete you will be asked twice to confirm you want to remove it.

Now the Public Folder database instance was removed from the domain the event log errors would stop, the next step was to remove the info Active Directory object. You need to use the View menu to enable Advanced Features then click on Microsoft Exchange System inside this container should be an object info that is listed as type Public Folder. Right click and Delete this.

Following the steps above has removed the info@domain.com account from the SMTP Routing Domain. This means you are free to create another object with that SMTP address, Exchange Server tends to appenx a number, such as 2 on duplicate SMTP addresses. For example if you have a mail-enabled Public Folder with the SMTP address of info@, Exchange will let you create a new user with the e-mail address info@ it is not util you look at the SMTP address of that user you will notice a 2 has been added.
To verify the info@ SMTP address had been removed I performed another search on Active Directory. As you can see it had removed it successfully.

In Exchange Server 2010 Public Folders are horrible to manage, therefore we decided the best way forward was to move to shared mailboxes. I used the Exchange Management Console to create a new account with the SMTP address info@domain.com. Public Folders are also a thing Microsoft seem to have been threating to remove since about Exchange Server 2007.

When the object created the Primary SMTP Address remains as info@ this is because there is no longer a duplicate within the SMTP domain.

As this was a shared mailbox I had to delegate permissions to allow other users to open it from their Outlook, this can be doing by right clicking on the mailbox and selecting Manage Full Access Permissions....

Use the Add button to add delegated user accounts to the Full Access Permissions group.

To add the shared mailbox to an existing users account you can edit the MAPI profile and use the Advanced tab and Add to simply point to the new mailbox.

Tested and it works.

This has obviously been an easy fix as there was no requirement to retain the data stored within the old Public Folders database. If you do need to recover the data there is a number of way to do it, you can patch up the database using ESEUTIL and hope for the best. Or you can use a 3rd party tool which can read and dump EDB files contents out to PST files. This would then allow you to do a manual restore from Outlook clients.