1

Using SXA 1.6 and Sitecore 9.01 I manage to enable Federated Authentication on CM so content editors can be authenticated using their Azure AD account using the guide from http://sitecore.badalkotecha.com/2017/11/federated-authentication-for-sitecore-9-integrating-with-azuread.html

I would like to do the same but for website visitor to login using their AD account, I add below code in one of my render

<div class="external-signin">

                  <a class="btn btn-default btn-block xp0.sc.azureAD" href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ExternalSignIn$ctl00$ctl00", "", false, "", "/identity/externallogin?authenticationType=xp0.sc.azureAD&amp;ReturnUrl=%252fidentity%252fexternallogincallback%253fReturnUrl%253d%2526sc_site%253dshell%2526authenticationSource%253dDefault&amp;sc_site=shell", false, true))'><div class="sc-icon" style="background-image: url(/sitecore/shell/themes/standard/Images/24x24/msazure.png)"></div>
                      <span class="external-signin-caption">
                          Sign-in with Azure Active Directory
                      </span>
                  </a>

        </div>

I get this issue

VM1085:1 Uncaught ReferenceError: WebForm_DoPostBackWithOptions is not defined
at <anonymous>:1:1

Is there anther way to achieve this?

  • is it treated as normal MVC site that integrated with Azure AD ? – user1534066 Mar 22 '18 at 18:58
0

Assuming you have properly configured the provider to handle your website authentication. Check <sites hint="list">.

You can get login URLs for your site through GetSignInUrlInfoPipeline pipeline. Do something like:

var corePipelineManager = DependencyResolver.Current.GetService<BaseCorePipelineManager>();
var args = new GetSignInUrlInfoArgs("website", url);
GetSignInUrlInfoPipeline.Run(corePipelineManager, args);

args.Result will have a list of the providers URLs available.

You need to do a POST request to these URLs. e.g

@foreach (var result in args.Result)
{
    using (Html.BeginForm(null, null, FormMethod.Post, new { @action = result.Href }))
    {
        <button type="submit">
            <img src="@result.Icon" />
            @result.Caption
        </button>
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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