Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Configure Exchange Autodiscover with a My Site Host URL in SharePoint Server 2013

SharePoint 2013
 

Applies to: SharePoint Server 2013

Topic Last Modified: 2014-02-20

Summary: Learn how to configure Exchange Autodiscover to find a user's SharePoint My Site URL.

In SharePoint Server 2013, a My Site gives users rich social networking and collaboration features that enable content sharing, discussions, and other features for users to do their jobs. The Exchange Server 2013 Autodiscover service configures profile settings on mail clients and mobile devices based on a supplied user name and password. The Autodiscover service can also be configured to allow for a simpler, seamless configuration experience to a My Site for Office 2013 client integration. For example, Office 2013 client and mobile phone apps can use Exchange Autodiscover to find a user's My Site based on the My Site Host URL stored in Active Directory Domain Services (AD DS). Instead of identifying and entering the My Site Host URL, a user’s email address and password are the only requirements to configure and provision client functionality for:

  • OneDrive for Business — Open and save a document to your OneDrive for Business location.

  • Access a Newsfeed on a device.

  • Office Hub — Set up the application on your Windows Phone.

This article provides the steps necessary to update AD DS with your My Site Host URL in SharePoint Server 2013. It also details the steps necessary to retrieve or remove the current My Site Host URL if you need to see the current value or replace it respectively.

ImportantImportant:
Before you proceed to the next section, you must already have your SharePoint Server 2013 and Exchange Server 2013 environments installed and configured. Additionally, you need to set up and configure My Sites in SharePoint Server 2013. For more information about how to implement My Sites and retrieve your My Site Host URL, see Configure My Sites in SharePoint Server 2013.

To update AD DS with the My Site Host URL, you must run a script on an Exchange Server computer by using the Exchange Management Shell. This procedure helps you create the Windows PowerShell script, and then run the script to update AD DS with the specified URL value. This procedure also provides the optional steps to verify and remove a My Site Host URL entry if needed. For more information about how to run scripts, see Scripting with the Exchange Management Shell in the Exchange Server 2013 Technical Library.

To configure Exchange Autodiscover with a My Site Host URL
  1. On an Exchange Server 2013 computer, copy the contents of the following script into Notepad. Save this file to any location and use a .ps1 extension to designate it as a Windows PowerShell script. Finally, rename the file SetMySiteHostURLInAD.ps1.

    function PrintUsage
    {
    @"
    
    NAME:
    SetMySiteHostURLInAD.ps1
    
    SYNOPSIS:
    The purpose of this script is to set My Site Host URL in Active Directory.
    This URL will be returned through Exchange Autodiscover.
    
    MySiteHostURL - URL of My Site Host to set in Active Directory.
    Or use -get to get My Site Host URL from Active Directory.
    Or use -remove to remove My Site Host URL from Active Directory.
    
    SYNTAX:
    SetMySiteHostURLInAD.ps1 "MySiteHostURL" | -get | -remove
    
    EXAMPLES:
    SetMySiteHostURLInAD.ps1 "http://my"
    SetMySiteHostURLInAD.ps1 -get
    SetMySiteHostURLInAD.ps1 -remove
    
    "@
    }
    
    function GetConfigurationNamingContextPath
    {
        return GetEntryProperty "LDAP://RootDSE" "configurationNamingContext"
    }
    
    function GetExchangePath
    {
        param([string]$configurationNamingContextPath)
    
        return "LDAP://CN=Microsoft Exchange,CN=Services," + $configurationNamingContextPath
    }
    
    function GetOrganizationContainerPath
    {
        param([string]$exchangePath)
    
        [string]$organizationContainerPath = ""
    
        ([ADSI] $exchangePath).Children | foreach {
          if (!$organizationContainerPath -and $_.SchemaClassName -eq "msExchOrganizationContainer") {
             $organizationContainerPath = $_.Path
                }
        }
    
        return $organizationContainerPath
    }
    
    function GetEntryProperty
    {
        param([string]$entryPath, [string]$propertyName)
    
        $entry = [ADSI] $entryPath
    
        [string]$value = ""
    
        trap {
             continue
        }
    
        $value = $entry.Get($propertyName)
    
        return $value
    }
    
    function SetEntryProperty
    {
        param([string]$entryPath, [string]$propertyName, [string]$propertyValue)
    
        $entry = [ADSI] $entryPath
    
        if (!$propertyValue)
        {
            $entry.PutEx(1, $propertyName, $null)
        }
        else
        {
            $entry.Put($propertyName, $propertyValue)
        }
    
        trap {
            Write-Host "`nError setting property" -ForegroundColor Red
            continue
        }
    
        $entry.SetInfo()
    }
    
    function AddOrReplaceOrRemoveMySiteHostURL
    {
        param([string]$old, [string]$url)
    
        [string]$separator = ";"
        [string]$label = "SPMySiteHostURL" + $separator
    
        if (!$old)
          {
             if (!$url)
                {
                  return ""
                }
             else
                {
                  return $label + $url
                }
          }
    
        [int]$labelPosition = $old.IndexOf($label)
        if ($labelPosition -eq -1)
          {
             if (!$url)
                {
                  return $old
                }
             else
                {
                  if ($old[$old.Length - 1] -eq $separator)
                  {
                  return $old + $label + $url
                  }
                  else
                  {
            return $old + $separator + $label + $url
                  }
                }
            }
    
        [int]$valuePosition = $labelPosition + $label.Length
    
        [int]$nextLabelPosition = $old.IndexOf($separator, $valuePosition)
         if ($nextLabelPosition -eq -1)
           {
             if (!$url)
             {
                  if ($labelPosition -eq 0)
                  {
                     return ""
                  }
                  else
                  {
                     return $old.Substring(0, $labelPosition - 1)
                  }
              }
             else
             {
                  return $old.Substring(0, $valuePosition) + $url
             }
          }
    
         if (!$url)
           {
              return $old.Substring(0, $labelPosition) + $old.Substring($nextLabelPosition + 1)
           }
          else
           {
              return $old.Substring(0, $valuePosition) + $url + $old.Substring($nextLabelPosition)
           }
    }
    
    if ($args.Count -ne 1)
    {
        Write-Host "`nError: Required argument missing or too many arguments" -ForegroundColor Red
        PrintUsage
        exit
    }
    
    if ($args[0] -eq "-?" -or $args[0] -eq "-h" -or $args[0] -eq "-help")
    {
        PrintUsage
        exit
    }
    
    [string]$url = ""
    if ($args[0] -ne "-r" -and $args[0] -ne "-remove")
    {
        $url = $args[0]
    }
    
    Write-Host "`nSetting My Site Host URL in Active Directory..."
    
    [string]$configurationNamingContextPath = GetConfigurationNamingContextPath
    Write-Host "`nConfiguration Naming Context path: $configurationNamingContextPath"
    
    [string]$exchangePath = GetExchangePath $configurationNamingContextPath
    Write-Host "`nExchange path: $exchangePath"
    
    [string]$organizationContainerPath = GetOrganizationContainerPath $exchangePath
    Write-Host "`nOrganization Container path: $organizationContainerPath"
    
    [string]$propertyName = "msExchServiceEndPointURL"
    Write-Host "`nProperty name: $propertyName"
    
    [string]$old = GetEntryProperty $organizationContainerPath $propertyName
    Write-Host "`nOld value: $old"
    
    if (!$url)
    {
        Write-Host "`nRemoving value"
    }
    elseif ($url -eq "-g" -or $url -eq "-get")
    {
        Write-Host ""
        exit
    }
    else
    {
        Write-Host "`nAdding or replacing value: $url"
    }
    
    [string]$new = AddOrReplaceOrRemoveMySiteHostURL $old $url
    Write-Host "`nNew value: $new"
    
    SetEntryProperty $organizationContainerPath $propertyName $new
    Write-Host ""
    
  2. On the Start menu, click All Programs.

  3. Click Microsoft Exchange Server 2013.

  4. Click Exchange Management Shell.

  5. In the Exchange Management Shell, navigate to the directory where you have saved the script and run the script with your specified My Site Host URL. For example, if you have a host URL of http://server/sites/contoso, the syntax might look like the following in the Exchange Management Shell:

    [PS] C:\>  c:\SetMySiteHostURLInAD.ps1      http://server/sites/contoso
    
  6. Press ENTER to run the script and update AD DS with the My Site Host URL.

  7. To verify that the correct URL was updated, run the following command:

    [PS] C:\>  c:\SetMySiteHostURLInAD.ps1      -get
    
    NoteNote:
    Optionally, you can remove a My Site Host URL by entering the command [PS] C:\> c:\SetMySiteHostURLInAD.ps1 -remove.

Once you have configured the My Site Host URL, you can also verify the value in SharePoint 2013 Central Administration. From Application Management, go to Manage service applications, to User Profile Service Application (or other chosen name for User Profile Service Application), to My Site Settings, and finally to Setup My Sites. On the My Site Settings page, you will see that the My Site Host URL in Active Directory field is populated with your entry.

My Site Host URL in Active Directory
NoteNote:
The My Site Host URL in Active Directory field cannot be populated through Central Administration, and My Site Host URL value must be supplied by using the previous detailed process.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.