2 Replies Latest reply on Jul 10, 2018 8:58 AM by shivi.goyal

    SAML SSO with Tableau Online in Dot NEt Application

    shivi.goyal

      Hi,

       

      I am developing a web application in dot net. I am trying to integrate Tableau Online in my application.

      I am trying to do SSO using SAML, but the sign in unsuccessful-

       

      following is my SAML Code-

       

        SAMLAssertion samlAssertion = new SAMLAssertion();

                  samlAssertion.Issuer = new Issuer("http://localhost:49747/Default.aspx");

                  samlAssertion.Version = "2.0";

                  samlAssertion.IssueInstant = System.DateTime.UtcNow;

                  samlAssertion.Conditions = new Conditions(System.DateTime.UtcNow, DateTime.UtcNow.AddMinutes(5));

        AttributeStatement attributeStatement = new AttributeStatement();

               

                  attributeStatement.Attributes.Add(new SAMLAttribute("email", "urn:oasis:names:tc:SAML:2.0:attrname-format:basic", null, tableauuseremailaddress));

                

                  samlAssertion.Statements.Add(attributeStatement);

       

       

                  SAMLResponse samlResponse = new SAMLResponse();

                  samlResponse.Destination = ACS URL provided on tableau server

                  Issuer issuer = new Issuer(ENtity ID provided on tableau server);

                  samlResponse.Issuer = issuer;

                  samlResponse.Status = new Status(SAMLIdentifiers.PrimaryStatusCodes.Success, null);

                  XmlElement samlAssertionElement = samlAssertion.ToXml();

       

       

                  Subject subject = new Subject(new NameID(tableauuseremailaddress, null, null, SAMLIdentifiers.NameIdentifierFormats.EmailAddress, null));

                  SubjectConfirmation subjectConfirmation = new SubjectConfirmation(SAMLIdentifiers.SubjectConfirmationMethods.Bearer);

                  SubjectConfirmationData subjectConfirmationData = new SubjectConfirmationData();

                  subjectConfirmationData.Recipient = "http://localhost:49747/Default.aspx";

                  subjectConfirmation.SubjectConfirmationData = subjectConfirmationData;

                  subject.SubjectConfirmations.Add(subjectConfirmation);

                  samlAssertion.Subject = subject;

       

                  AuthnStatement authnStatement = new AuthnStatement();

                  authnStatement.AuthnContext = new AuthnContext();

                  authnStatement.AuthnContext.AuthnContextClassRef = new AuthnContextClassRef(SAMLIdentifiers.AuthnContextClasses.Password);

                  samlAssertion.Statements.Add(authnStatement);

       

                  samlResponse.Assertions.Add(samlAssertionElement);

       

      X509Certificate2 spCert = (X509Certificate2)Application[certificate provided by tableau];

       

              SAMLMessageSignature.Generate(samlResponseXml, spCert.PrivateKey, spCert);

       

        IdentityProvider.SendSAMLResponseByHTTPPost(Response,ACS URL provided on tableau server , samlResponseXml, relayState);

       

      Thanks in advance!