Using UDP-SIP with Exchange UM and Lync 2010

Attachment: https://bennettadelson.wordpress.com/2012/06/04/using-udp-sip-with-exchange-um-and-lync-2010/kamailio-cfg/ (remember to change extension)

Attachment: asterisk.tar.gz (remember to change extension)

I am working on and off with a client that is deploying Exchange 2010 Unified Messaging and Lync 2010 in their environment. They want to use Exchange UM with a hosted SIP-based VoIP system from a provider that I will refer to as “PhoneCo” for the sake of discussion. Furthermore, they want their Lync environment to work with the Exchange voicemail, and by the way, think it would be nice if they could experiment with Enterprise Voice functionality. Luckily, PhoneCo offers SIP trunks, and will trunk from the hosted VoIP environment to Exchange UM. So all is good, right?

The Problem Statement

Ha ha, of course I am joking. Because although Microsoft talks SIP, and PhoneCo talks SIP, we hit upon a long-standing issue. Microsoft refuses to support UDP SIP (they have their reasons, I won’t debate the point here) while PhoneCo refuses to support TCP SIP. Thus, we have an impasse.

Solution Overview

The official, standard answer to this is to use a Session Border Controller (SBC), which is essentially a SIP middleman box that can do UDP on one end and TCP on the other. A typical SBC also includes firewalling intelligence to prevent denial-of-service and other such nasty behavior. As a result, they generally start at thousands and quickly get into tens of thousands of dollars. In this customer’s case, the SIP trunk is going to be over a private MPLS connection directly between the hosted PBX and the on-premises Microsoft tools, so the customer didn’t want to pay for a lot of security they didn’t need just to deal with this issue.

The customer found a commercial product named Brekeke SIP Server that appears to be $500 to start. This is nice in that (1) it is commercial and (2) it can run on Windows, although it is Java-based so it’s a little messy and gives you one more thing to deal with patching every day or two.

We wanted to see if there was an open-source way to solve this problem. We found a way, and this post documented what we came up with. I have replicated the scenario in a lab, and have since actually simplified things a bit. I have also corrected something we had done to work around an Asterisk “bug” (in quotes because the bug states it’s not really an Asterisk bug) that came up while we were simulating the PhoneCo setup.

So first, here’s the list of VMs that are in the UC Lab:

Hostname IP Description
dc.uclab.local 172.30.1.10 Domain Controller
exchange.uclab.local 172.30.1.12 Exchange 2010
freepbx.uclab.local 172.30.1.11 PhoneCo stand-in
lync.uclab.local 172.30.1.13 Lync 2010
siprouter.uclab.local 172.30.1.14 SIP middleman
tmg.uclab.local 172.30.1.1 TMG 2010
internalclient.uclab.local 172.30.1.100 Test Lync/SIP client

The PhoneCo stand-in is a FreePBX installation using the FreePBX Linux distribution. I am not going to go into details on installing that into a VM because there are plenty of guides on getting that to work. For the purposes of this post I’m going to pretend Asterisk can’t do TCP SIP because that’s what we are looking at with PhoneCo. This also means ignoring all the online info about getting Asterisk to talk to Lync and Exchange using TCP SIP. (Note: Some of these guides assuming port 5065 for talking to Exchange, which is a partial solution. I’ll get into why that’s wrong later on.)

The SIP middleman – SIP router – is a Linux-based CentOS machine running the Kamailio open-source SIP router package. Kamailio is a mature, solid package that is quite amazing in some of what it can do, but I’m ignoring about 99% of it, I think. We may end up needing some of the NAT support eventually at the client, which I’m not getting into here and don’t need for the lab, but otherwise a lot of functionality is actually not in play here.

Preparing the CentOS Machine

So let’s get to it.

  1. I began with a basic minimal CentOS 6.2 installation. Note that I’ve had repeated issues with the Hyper-V Integration Components on this OS so far, so I didn’t bother with them – for a lab it’s not critical. For production you’d care a lot more – the customer uses VMware so this particular issue did not come up.
  2. Next, I logged in as root via SSH (PuTTY is your friend here) and accepted the key when prompted:
    image
    image
  3. I ran yum updateto get all of the current updates for the OS, and rebooted to get the updated kernel loaded.
  4. Using vi, I created /etc/yum.repos.d/kamailio.repowith:
    [kamailio]
    name=Kamailio
    baseurl=http://download.opensuse.org/repositories/home:/kamailio:/telephony/CentOS_CentOS-6/
    enabled=1
    gpgcheck=0

    This looks like this:

    clip_image001

  5. I confirmed that the new repository was visible with yum repolist:clip_image002
  6. I then confirmed that there was a package I could install in that repository with yum list kamailio:
    clip_image003
  7. After confirming the package, I installed it with yum install kamailio:
    clip_image004

    clip_image005
  8. So now I need to configure the beast. Kamailio comes with a very long sample configuration file. Most of it is noise for my use. I tried to trim it down as safely as possible, as well as better fit what I wanted. So using the following commands I saved the shipped file:
    cd /etc/kamailio
    mv kamailio.cfg kamailio.cfg.original
    vi /etc/kamailio.cfg

    And then made mine, which I will explain later after finishing the build instructions:

    #!KAMAILIO
    
    # Remote Hosts
    #!subst "/SIP_UDP_HOST/172.30.1.11/"
    #!subst "/EXCHANGE_UM/172.30.1.12/"
    #!subst "/LYNC_MEDIATION/172.30.1.13/"
    
    listen=172.30.1.14:5060
    listen=172.30.1.14:5065
    listen=172.30.1.14:5067
    
    ####### Global Parameters #########
    
    memdbg=5
    memlog=5
    
    debug=2
    
    log_facility=LOG_LOCAL0
    
    fork=yes
    children=4
    
    disable_tcp=no
    
    auto_aliases=no
    
    /* uncomment and configure the following line if you want Kamailio to
       bind on a specific interface/port/proto (default bind on all available) */
    #listen=udp:10.0.0.10:5060
    
    # life time of TCP connection when there is no traffic
    # - a bit higher than registration expires to cope with UA behind NAT
    tcp_connection_lifetime=3605
    
    ####### Modules Section ########
    
    mpath="/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/"
    
    loadmodule "kex.so"
    loadmodule "tm.so"
    loadmodule "tmx.so"
    loadmodule "sl.so"
    loadmodule "pv.so"
    loadmodule "maxfwd.so"
    loadmodule "usrloc.so"
    loadmodule "textops.so"
    loadmodule "siputils.so"
    loadmodule "xlog.so"
    loadmodule "sanity.so"
    loadmodule "ctl.so"
    loadmodule "cfg_rpc.so"
    loadmodule "mi_rpc.so"
    
    # ----- tm params -----
    # auto-discard branches from previous serial forking leg
    modparam("tm", "failure_reply_mode", 3)
    # default retransmission timeout: 30sec
    modparam("tm", "fr_timer", 30000)
    # default invite retransmission timeout after 1xx: 120sec
    modparam("tm", "fr_inv_timer", 120000)
    
    server_header="Server: PhoneCo Intransigence Coping Solution (PICS) 2.0";
    
    ####### Routing Logic ########
    route {
            if(is_method("OPTIONS")) {
                    xlog("L_INFO","OPTIONS from $si");
                    sl_send_reply("200", "Yes, Microsoft, I am alive");
                    exit();
            }
    
            xlog("L_INFO", "*** M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci");
    
            # Route Exchange extensions
            if((to_uri=~"sip:5992") || (to_uri=~"sip:5999")) {
                    xlog("L_NOTICE", "EXCHANGE UM call, $proto port $op, $ru, $fU");
                    t_on_reply("1");
    
                    # https://issues.asterisk.org/jira/browse/ASTERISK-16862
                    # http://imaucblog.com/archive/2009/10/03/part-1-how-to-integrate-exchange-2010-or-2007-with-trixbox-2-8/
                    replace("Diversion: <sip:5999@SIP_UDP_HOST>;reason=unconditional","MCB-Stripped-Header: Diversion");
    
                    switch($op) {
                            case 5060:
                                    xlog("L_NOTICE", "Redirecting to TCP 5060");
                                    t_relay_to("tcp:EXCHANGE_UM:5060");
                                    exit();
                                    break;
                            case 5065:
                                    xlog("L_NOTICE", "Redirecting to TCP 5065");
                                    t_relay_to("tcp:EXCHANGE_UM:5065");
                                    exit();
                                    break;
                            case 5067:
                                    xlog("L_NOTICE", "Redirecting to TCP 5067");
                                    t_relay_to("tcp:EXCHANGE_UM:5067");
                                    exit();
                                    break;
                    }
            }
    
            # Route Lync extensions
            if(to_uri=~"sip:5...") {
                    replace("To: <sip:", "To: <sip:+");
                    xlog("L_NOTICE", "LYNC call to $tu");
                    t_relay_to("tcp:LYNC_MEDIATION:5068");
                    exit();
            }
    
            # Route the rest to Asterisk
            xlog("L_NOTICE", "Asterisk call to $tu");
            forward_udp("SIP_UDP_HOST", 5060);
    }
    
    onreply_route[1] {
            xlog("L_NOTICE", "Handling reply from Exchange relay, status $rs");
            switch($rs) {
                    case 302:
                            xlog("L_NOTICE", "Saw 302 Redirect response, checking details...");
                            if(search(";transport=Tcp")) {
                                    xlog("L_NOTICE", "Saw TCP redirection, changing redirection to UDP");
                                    replace(";transport=Tcp", ";transport=Udp");
                            } else {
                                    xlog("L_NOTICE", "302 was not matched (!)");
                            }
                            exit();
                            break;
                    case 100:
                            xlog("L_NOTICE", "Saw 100, leaving alone...");
                            exit();
                            break;
            }
    
    }

     

  9. I stared the daemon (read: service) with /etc/rc.d/init.d/kamailio start and confirmed that it started  with /etc/rc.d/init.d/kamailio status:clip_image001
  10. I confirmed it was listening (netstat –an | grep 506):clip_image002
  11. I then opened up the firewall to allow those ports in (okay, thats a lie – I floundered a bit before remembering I had to do this) by editing /etc/sysconfig/iptables and adding after the --dport 22line:
    		-A INPUT -p tcp -m state --state NEW -m tcp --dport 5060 -j ACCEPT
    		-A INPUT -p tcp -m state --state NEW -m tcp --dport 5065 -j ACCEPT
    		-A INPUT -p tcp -m state --state NEW -m tcp --dport 5067 -j ACCEPT
    		-A INPUT -p udp -m state --state NEW -m udp --dport 5060 -j ACCEPT
    		-A INPUT -p udp -m state --state NEW -m udp --dport 5065 -j ACCEPT
    		-A INPUT -p udp -m state --state NEW -m udp --dport 5067 -j ACCEPT

    This looks like this when it’s done:
    image

  12. I then made this kick in by restarting the firewall with /etc/rc.d/init.d/iptables restart.
  13. I next added system logger support for the configured log source by editing /etc/rsyslog.confand adding:
    local0.*                                                 /var/log/kamailio.log

    image

  14. I then made this kick in by reloading the logger configuration with /etc/rc.d/init.d/syslog reload.
    image
  15. I don’t want this log to grow uncontrollably so I configured the logrotate daemon to make a new log every day and save seven of them by creating /etc/logrotate.d/kamailiowith:
    /var/log/kamailio.log {
    	rotate 7
    	missingok
    	daily
    }

    image

Preparing Exchange 2010 and Lync 2010

This is normal Exchange and Lync SIP configuration so I’m not going to get into great detail here. The following are the key points:

  • Make sure Lync has a TCP listener on port 5068 on the mediation server of your choice. There’s no high availability here so pick one and go. As quick hints of where this is done in Topology Builder:
    clip_image001[7]
    clip_image002[8]
    After publishing and running Bootstrapper (Lync Setup) on the Mediation Server as instructed by Topology Builder I ran into (what I consider to be) a bug in Lync shown via the event log – there were LS Mediation Server messages 25075 and 25031 indicating no TCP port is enabled, then that the TCP port was requested but ignored. Restarting the Mediation Server service sorted it out. The Kamailio log will show this working (e. g. tail /var/log/kamailio.log):
    image
  • For Exchange, make sure you have TCP enabled on the UM server (requires a service restart to kick in) and that you have an appropriate IP gateway and unsecured telephone extension dial plan configured against that gateway:
    clip_image001[9]
    clip_image002[10]

And that’s it!

So What Does the Configuration Mean?

OK, so what the heck does the configuration I gave you above mean?  Let’s go through it:

#!KAMAILIO

This is a signature for the configuration file.

# Remote Hosts

#!subst "/SIP_UDP_HOST/172.30.1.11/"
#!subst "/EXCHANGE_UM/172.30.1.12/"
#!subst "/LYNC_MEDIATION/172.30.1.13/" 

listen=172.30.1.14:5060
listen=172.30.1.14:5065
listen=172.30.1.14:5067

This is the super important customization part. The three subst lines replace all references to those text strings with the appropriate IP addresses, while the listen lines allow the router to accept traffic on its IP on three ports – 5060, 5065, and 5067. The latter two are because Exchange – for reasons known to Microsoft but not me – takes UM connections on port 5060 but then redirects them to 5065 or 5067. Remember how above I said that some sites use 5065 and that’s wrong?  That’s because they are assuming all redirects are to 5065, but Exchange might want 5067.

Anyway, the next lines are some configuration stuff that is from the default that I left alone mainly because either the settings were fine (e. g. the syslog facility used) or because I didn’t know the implications in changing them (e. g. the children process count); there’s also the enabling of TCP (normally disabled):

####### Global Parameters ######### 
memdbg=5

memlog=5 
debug=2
log_facility=LOG_LOCAL0 
fork=yes

children=4 
disable_tcp=no 
auto_aliases=no 

# life time of TCP connection when there is no traffic
# - a bit higher than registration expires to cope with UA behind NAT
tcp_connection_lifetime=3605

Next are the modules that I am loading. I know I need some of these for sure – there are others I don’t know about so I left well-enough alone and kept them there:

####### Modules Section ######## 
mpath="/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/" 
loadmodule "kex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "mi_rpc.so" 

# ----- tm params -----
# auto-discard branches from previous serial forking leg
modparam("tm", "failure_reply_mode", 3)
# default retransmission timeout: 30sec
modparam("tm", "fr_timer", 30000)
# default invite retransmission timeout after 1xx: 120sec
modparam("tm", "fr_inv_timer", 120000)

The next line sets a server header seen in the SIP headers. It is a fun way to point out that PhoneCo was annoying me as well as to hide the actual software being used:

server_header="Server: PhoneCo Intransigence Coping Solution (PICS) 2.0"

Now comes the real meat. It starts the routing logic for incoming SIP calls looking for the OPTIONS call that Lync and Exchange make every nanosecond (approximately) to check to see if their SIP peers are alive. Hence the status text – the code is all that really matters:

####### Routing Logic ########

route {
        if(is_method("OPTIONS")) {
                xlog("L_INFO","OPTIONS from $si");
                sl_send_reply("200", "Yes, Microsoft, I am alive");
                exit();
        }

The next line just acts as a debugging log showing what came in:

        xlog("L_INFO", "*** M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci");

The dollar-sign pseudo-variables are documented here, should you care: http://www.kamailio.org/wiki/cookbooks/3.2.x/pseudovariables

Anyway, moving on, we have the Exchange routing. Looking at this now, I probably want the two extensions (one for the auto-attendant and one for subscriber access) to be substituted variables, but that will be 2.1 I guess:

# Route Exchange extensions
        if((to_uri=~"sip:5992") || (to_uri=~"sip:5999")) {
                xlog("L_NOTICE", "EXCHANGE UM call, $proto port $op, $ru, $fU");
                t_on_reply("1");

This basically says “if a SIP call is made to extension 5992 or extension 5999, then do this…” and starts by indicating that we are going to do a transactional SIP redirect that, when we see a reply, should go to reply handler “1“, which will come later. After that, we have:

        # https://issues.asterisk.org/jira/browse/ASTERISK-16862
        # http://imaucblog.com/archive/2009/10/03/part-1-how-to-integrate-exchange-2010-or-2007-with-trixbox-2-8/
        replace("Diversion: <sip:5999@SIP_UDP_HOST>;reason=unconditional","MCB-Stripped-Header: Diversion");

Why is this here? Basically, Asterisk does something we don’t want it to do on the Exchange redirect – adds an extra SIP Diversion header – and we want that extra header to go away. I need to replace it with something though, so I just made up a vendor header and used that. This is safe as SIP agents – like HTTP server and clients – ignore headers that they don’t know. Next, we take the UDP session and do a transactional redirect to TCP:

        switch($op) {
                case 5060:
                        xlog("L_NOTICE", "Redirecting to TCP 5060");
                        t_relay_to("tcp:EXCHANGE_UM:5060");
                        exit();
                        break;
                case 5065:
                        xlog("L_NOTICE", "Redirecting to TCP 5065");
                        t_relay_to("tcp:EXCHANGE_UM:5065");
                        exit();
                        break;
                case 5067:
                        xlog("L_NOTICE", "Redirecting to TCP 5067");
                        t_relay_to("tcp:EXCHANGE_UM:5067");
                        exit();
                        break;
                }
        }

I couldn’t come up with a “smart” way to do this better; this is a little wordy but it is clear what is happening. I next route the Lync calls (adding the E.164 “+” sign along the way) based on extension pattern (all other 5xxx extensions besides the two special case ones above), with all others going to the Asterisk side:

        # Route Lync extensions
        if(to_uri=~"sip:5...") {
                replace("To: <sip:", "To: <sip:+");
                xlog("L_NOTICE", "LYNC call to $tu");
                t_relay_to("tcp:LYNC_MEDIATION:5068");
                exit();
        }

        # Route the rest to Asterisk
        xlog("L_NOTICE", "Asterisk call to $tu");
        forward_udp("SIP_UDP_HOST", 5060);
}

Notice that I do forward_udpinstead of t_relay_to because I don’t care about maintaining transactional state in the case of going back to Asterisk, so there’s no reason to waste resources on it. I just tell Kamailio to throw it over the wall and forget about it.

Finally, I handle the reply from Exchange. This is why I made the Exchange piece transactional:

onreply_route[1] {
        xlog("L_NOTICE", "Handling reply from Exchange relay, status $rs");
        switch($rs) {
                case 302:
                        xlog("L_NOTICE", "Saw 302 Redirect response, checking details...");
                        if(search(";transport=Tcp")) {
                                xlog("L_NOTICE", "Saw TCP redirection, changing redirection to UDP");
                                replace(";transport=Tcp", ";transport=Udp");
                        } else {
                                xlog("L_NOTICE", "302 was not matched (!)");
                        }
                        exit();
                        break;
                case 100:
                        xlog("L_NOTICE", "Saw 100, leaving alone...");
                        exit();
                        break;
        }

Notice if I get a redirect from Exchange (which I will for port 5060) I change that from a Tcp redirect to a Udp redirect, then send it on its way.

So, this is what is in the lab right now. I think this works – until PhoneCo gets the line in place we won’t know 100% but I think this is close if it isn’t completely right. We’ll see.

Hope this helps you in your integration scenarios!

— Michael C. Bazarewsky
Principal Consultant, Windows Server and Security

FIM 2010 with Exchange 2010 Configuration for provisioning

FIM 2010 with Exchange 2010 Configuration for provisioning

FIM 2010 can help provision users account while creating Exchange 2010 mail account. With this process below, we will see how FIM 2010 can create Exchange mailboxes when accounts are created in FIM 2010.

FIM Synchronization Service Manager:

In FIM 2010 Synchronization Service make sure to enable Exchange 2010 Rule Extension:

Select Tools > Options

Check the Enable metaverse rules extension

Select Browse and select Exch2010Extenstion.dll (See Below):

Then in the FIM AD MA make sure to configure the extension:

Select the Configure Extension

Select the drop down Provision for: and select Exchange 2010.

In the Exchange 2010 RPS URI put in : http://<the cas server name>/Powershell. Make sure the powershell web site is enabled for this extension to work.

Exchange 2010 Configuration:

After we have this configured, we need to make sure that an account can create mailboxes in Exchange. In exchange make sure the domain FIM sync account as the proper administrative rights to create mailboxes. Test the account by updating an account and providing them a mailbox. If the FIM sync account can’t create or update a mailbox then the permissions are incorrect.

FIM 2010 Service and Portal:

In the FIM Portal, the synchronization rule outbound will need to be configured for creating the mailbox in Exchange. We do this by updating the MS Exchange attributes in AD. Below is how we configure this rule.

Navigate to the FIM Portal

Select Administration > Synchronization Rules.

Select the outbound rule that has been created for users. If this is not created you must create an outbound rule for AD users.

On the AD Synchronization rule select the Outbound Attribute flow.

Create the five outbound attribute flows below with Initial Flow Only:

1. /o=/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=-> MSEXCHANGEHOMEServerName

2. CN=Default Role Assignment Policy,CN=Policies,CN=RBAC,CN=DomainName,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DomainName,DC=Com->  MSExchangeRBACPolicyLink

3. CN=<servername of home MDB>,CN=Databases,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=DomainName,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DomainName,DC=Com ->HomeMDB

If you have multiple databases for HomeMDB you can create a random number to be created for each database. Lets say there are 8, in the attribute flow add the function for the HomeMDB: CN=RandomNum(1,8)

4.  .domainname-> userprincipalName
Example: tester.testdomain.org

5. true -> MDBUseDefaults

Additional attributes that need created for a user are the useraccountcontrol and UnicodePswd. These are needed to create an account in AD. If these attributes are not set please do them so you can get the account created in AD.

Final steps:

1. Create an account in the FIM 2010 Portal

2. Synchronize the FIM MA

3. Export the FIM AD MA

4. Check the attributes in AD

5. Logon with the new account in Outlook or Outlook Web.

Overview:

As you can see it is not difficult to configure FIM 2010 to create mail accounts in Exchange 2010. The process below can reduce administration in AD and Exchange by allowing FIM to control the account creation for AD and Exchange mail account.

Thanks,
Active Directory and Identity and Access Management Principal Engineer
Nathan Mertz | Bennett Adelson | Columbus

Exchange 2010 RTM Setup Fails with Event ID 1002

While working through an Exchange 2010 RTM installation (to be updated to SP2 of course when the time came) at a customer site, we ran into an error that at first had us baffled:

Exchange Server component Mailbox Role failed.
Error: Error:
The following error was generated when “$error.Clear();
$name = [Microsoft.Exchange.Management.RecipientTasks.EnableMailbox]::DiscoveryMailboxUniqueName;
$dispname = [Microsoft.Exchange.Management.RecipientTasks.EnableMailbox]::DiscoveryMailboxDisplayName;
$dismbx = get-mailbox -Filter {name -eq $name} -IgnoreDefaultScope -resultSize 1;
if( $dismbx -ne $null)
{
$srvname = $dismbx.ServerName;
if( $dismbx.Database -ne $null -and $RoleFqdnOrName -like “$srvname.*” )
{
Write-ExchangeSetupLog -info “Setup DiscoverySearchMailbox Permission.”;
$mountedMdb = get-mailboxdatabase $dismbx.Database -status | where { $_.Mounted -eq $true };
if( $mountedMdb -eq $null )
{
Write-ExchangeSetupLog -info “Mounting database before stamp DiscoverySearchMailbox Permission…”;
mount-database $dismbx.Database;
}

              $mountedMdb = get-mailboxdatabase $dismbx.Database -status | where { $_.Mounted -eq $true };
if( $mountedMdb -ne $null )
{
$dmRoleGroupGuid = [Microsoft.Exchange.Data.Directory.Management.RoleGroup]::DiscoveryManagementWkGuid;
$dmRoleGroup = Get-RoleGroup -Identity $dmRoleGroupGuid -DomainController $RoleDomainController -ErrorAction:SilentlyContinue;
if( $dmRoleGroup -ne $null )
{
Add-MailboxPermission $dismbx -User $dmRoleGroup.Identity -AccessRights FullAccess -DomainController $RoleDomainController -WarningAction SilentlyContinue;
}
}
}
}
” was run: “Couldn’t resolve the user or group “domain.local/Microsoft Exchange Security Groups/Discovery Management.” If the user or group is a foreign forest principal, you must have either a two-way trust or an outgoing trust.”.

Couldn’t resolve the user or group “domain.local/Microsoft Exchange Security Groups/Discovery Management.” If the user or group is a foreign forest principal, you must have either a two-way trust or an outgoing trust.

The trust relationship between the primary domain and the trusted domain failed.

The bolded portion was the key, although we (okay, I – MCB) completely misread it.  We took this to mean that it was an issue with the member server trust, but that of course is a completely different error:

The trust relationship between this workstation and the primary domain failed.

We (okay, I – TB) finally figured out what was up – the customer had two broken domains trusts in the environment.  When asked, the customer said, “oh, yeah, I think we know about that, they are before anyone’s time and we were afraid to touch them.”  That of course was not a helpful answer, but they were onboard with whacking the trusts since they didn’t work anyway.

One of the things that caused us pain here is that there are substantial number of web pages and forum posts about this particular error, but they all relate to SP installation on an existing installation.  They go through recreating system mailboxes and all kinds of other hoops, but that was in our case the completely wrong thing to do.

Once we removed the bad trusts, the installation worked.  Yay.  It’s a case perhaps of “RTFEM.”  There’s a good question here of exactly why Exchange Setup cares here – it knows enough information to find the group in question without going through trusts, but it insists on doing so anyway.  One could even go so far as to this being a bug, although without knowing the team’s reasoning it’s difficult to jump to that conclusion.

In any event, hopefully this post helps other people out.

– Tom Bridge and Michael C. Bazarewsky
”Exchange Rock Stars” (Tom made us say that)