Using an Office 365 SharePoint Online Hybrid Mysite solution

While recently working with one of my customers on configuring their Office 365 SharePoint Online Hybrid Mysite solution, we noticed some glitches to be aware of when pointing an on-premises farm (SP2010 and/or SP2013) directly to the
https://<tenantname> url as a Trusted MySite Host Location.

Yes the MySite/SkyDrive links will work fine...However certain operation like clicking on a users name under the "Modified By" column in an on-prem library

will fail with the following error

This is because SharePoint on-prem is passing the user context to Office 365 as accountname=DORADOJOES\elib\elib

 rather than accountname=i:0#.f|membership||membership|


To avoid this issue, you may want to implement a solution similar to the one below in which we provisioned a custom.aspx page (sample code below) in the on-premises SharePoint farm that performs a string manipulation against the accountname so its formatted properly before being passed to O365

-    Drop that custom.aspx page into the Layouts directory on all on-prem SP servers,

-    Then rather than pointing to https://<tenantname> url as a Trusted MySite Host Location, you point to http://<onpremMySiteHost>/_layouts/custom.aspx as the Trusted MySite Host Location instead.


NOTE: you will need to change <tenantname> to the actual name of your O356 tenant

ex. ""   

 <script language="CS" runat="server">
 void Page_Load(object sender, System.EventArgs e)
 string account = Request.QueryString["accountname"];
 if(account != null)
 // Extract domain and name of user from the account name
 int stop = account.IndexOf("\\");
 string domain = account.Substring(0, stop);
 string user = account.Substring(stop + 1, account.Length - stop - 1);
 // Construct the SPO URL to redirect to
 string spoUser = String.Format("i:0#.f|membership|{0}@{1}.com", user, domain);
 string spoUrl = "https://<tenantname>" + Server.UrlEncode(spoUser);
 // Redirect to profile page in SPO
 // Handle error as necessary



Go Cloud!!!