Compartir a través de


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>-my.sharepoint.com 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

https://proseware-my.sharepoint.com/Person.aspx?accountname=Contoso\elib

 rather than accountname=i:0#.f|membership|elib@doradojoes.com

https://proseware-my.sharepoint.com/Person.aspx?accountname=i:0#.f|membership|elib@contoso.com

 

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>-my.sharepoint.com url as a Trusted MySite Host Location, you point to https://<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. "https://contoso-my.sharepoint.com/Person.aspx?accountname="   

 <html>
 <head>
 <script language="CS" runat="server">
 void Page_Load(object sender, System.EventArgs e)
 {
 try
 {
 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>-my.sharepoint.com/Person.aspx?accountname=" + Server.UrlEncode(spoUser);
 
 // Redirect to profile page in SPO
 Response.Redirect(spoUrl);
 }
 }
 catch
 {
 // Handle error as necessary
 throw;
 }
 }
 </script>
 </head>
 </html>
 

 

 

Go Cloud!!!

Comments

  • Anonymous
    December 21, 2013
    thanks for this, very helpful.  i had to make some changes to get this to work.  i posted about it here: sharepoint.stackexchange.com/.../how-to-use-sharepoint-online-my-site-host-location-with-sharepoint-2013-on-premi

  • Anonymous
    January 27, 2014
    Hi there, Thank you for sharing this useful tip. I am trying to configure SharePoint 2013 Hybrid and have been following TechNet documentation. The article specifies we use NTLM authentication for SharePoint but how does single sign on work outside the network? Can you please clarify?

  • Anonymous
    August 08, 2014
    Hello jvasilSP, it greats to have this custom solution. i am in charge for redirect mysites on our SP2010 environemnt to mysite on SharePoint Online. I have tried to do same as instruction but unfortunately it seems doesn't work for me. Do we need to restart something to take it's effected after we change the mysites setting on Premise. Please let me know. Thanks and much appreciate, Kong

  • Anonymous
    December 14, 2014
    Hello, Thanks for this post this works great, after slightly changing the code. however this affects how my newsfeed run and it also doesn't work when viewing a User's Profile. The link to view user profile is not the same as the one mentioned above. any ideas?

  • Anonymous
    April 30, 2015
    This a bad idea. I would suggest setting up ADFS so that the users are logging into the on prem farm and SPO with the same account.