1

I have a website that connects to a SharePoint online site in order to access content from there. The authentication is done through the Office 365 login. In order to do that, I composed the following URL:

https://login.microsoftonline.com/login.srf?wa=wsignin1.0&rpsnv=3&rver=6.1.6206.0&wp=MBI&wreply=https://www10226.sharepoint.com/_layouts/15/landing.aspx?Source=" + window.location

so that the window.location is returned to after the authentication is done. It worked so far, but today I encountered the following problem: https://www10226.sharepoint.com now says page cannot be found, DNS lookup failed. Apparently the correct address is now https://www10501.sharepoint.com . Does anybody know about this sort of change? Is it a one time thing or it happens on a regular basis? How can I get the right DNS dynamically so my code won't be affected by changes like this one in the future?

Any help is highly appreciated.

1 Answer 1

1

If anyone ever has the same problem, I found a solution to this: instead of hardcoding the wreply parameter, I first access the SharePoint site + "/_forms/default.aspx" with a request that does not follow redirects and has the user agent set. The response has a Location header that I get and which contains a wreply parameter. Only the left part (in the Uri left part - authority sense) is of interest. After you get that you should add the suffix "/_layouts/15/landing.aspx" and that is the value of the wreply parameter, regardless of the DNS changes in CNAME that occur regularly to some Office 365 tenants.

This is a solution meant to work with multiple SharePoint online addresses, migrated or older versions, default CNAME set or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.