Example #1
0
        protected void LinkButtonExistingUser_Click(object sender, EventArgs e)
        {
            StartRegistrationAttemptResponse response = null;

            try
            {
                using (WebSSOServiceSoapClient client = new WebSSOServiceSoapClient("WebSSOServiceSoapClient"))
                {
                    client.Open();

                    StartExistingUserRegistrationAttemptRequest request = new StartExistingUserRegistrationAttemptRequest()
                    {
                        // In this example, SuccessUri and FailureUri are set to the same value. The response
                        // to each End<X>Attempt() contains enough information to distinguish
                        // between a success result and a failure result. SignUpExistingResult.aspx illustrates
                        // how to do this.
                        SuccessUri = ConfigurationManager.AppSettings["SignUpExistingResultUri"],
                        FailureUri = ConfigurationManager.AppSettings["SignUpExistingResultUri"],

                        // The user will be signed on following a successful registration, so we need to
                        // specify the application session length.
                        SessionLengthMinutes = HttpContext.Current.Session.Timeout,
                        SessionLengthMinutesSpecified = true,

                        CancelAllowed = true
                    };

                    response = client.StartExistingUserRegistrationAttempt(request);
                }
            }
            catch (Exception ex)
            {
                LabelMessage.Text = HttpUtility.HtmlEncode(string.Format("Exception of type {0} raised when calling WebSSOService.StartExistingUserRegistrationAttempt(). {1}", ex.GetType().FullName, ex.Message));
            }

            if (response != null)
            {
                // The registration attempt ID is placed in the session to act as a "marker" that
                // a registration attempt is in progress. It's used later to avoid a call to
                // EndExistingUserRegistrationAttempt() if no registration attempt is in progress.

                Session["ExistingUserRegistrationAttempt"] = response.RegistrationAttemptId;

                Response.Redirect(response.RedirectUri);
            }
        }
        public ActionResult RegisterExisting()
        {
            StartRegistrationAttemptResponse response = null;

            try
            {
                using (WebSSOServiceSoapClient client = new WebSSOServiceSoapClient("WebSSOServiceSoapClient"))
                {
                    client.Open();

                    StartExistingUserRegistrationAttemptRequest request = new StartExistingUserRegistrationAttemptRequest()
                    {
                        // In this example, SuccessUri and FailureUri are set to the same value. The response
                        // to each End<X>Attempt() contains enough information to distinguish
                        // between a success result and a failure result. RegisterExistingResult() illustrates
                        // how to do this.
                        SuccessUri = RegisterExistingResultUri,
                        FailureUri = RegisterExistingResultUri,

                        CancelAllowed = true,

                        // The user will be signed on following a successful registration, so we need to
                        // specify the application session length.
                        SessionLengthMinutes = HttpContext.Session.Timeout,
                        SessionLengthMinutesSpecified = true,
                    };

                    response = client.StartExistingUserRegistrationAttempt(request);
                }
            }
            catch (Exception ex)
            {
                Session["Message"] = HttpUtility.HtmlEncode(string.Format("Exception of type {0} raised when calling WebSSOService.StartExistingUserRegistrationAttempt(). {1}", ex.GetType().FullName, ex.Message));

                return SignUpPageRedirect;
            }

            // The registration attempt ID is placed in the session to act as a "marker" that
            // a registration attempt is in progress. It's used later to avoid a call to
            // EndNewUserRegistrationAttempt() if no registration attempt is in progress.

            Session["ExistingUserRegistrationAttempt"] = response.RegistrationAttemptId;

            return Redirect(response.RedirectUri);
        }