Page 1 of 1

Single Sign On (SSO) Code

Posted: Sun May 22, 2011 7:36 am
by aferrara
I have built the following function to accept a user from an external system, and authenticate in AC7 (706 if it matters). This works, but I would like to ask the gurus here if you could advise if this is the appropriate way to handle single sign on. I appreciate all comments.

Code: Select all

                    CommerceBuilder.Users.User loginUser = UserDataSource.LoadForUserName(myUser);
                    if (loginUser != null)
                    {
                        if ((Token.Instance.UserId != loginUser.UserId) && (loginUser.UserId != 0))
                        {
                            //CommerceBuilder.Users.User.Migrate(UserDataSource.Load(loginUser.UserId), Token.Instance.User);
                            CommerceBuilder.Users.User.Migrate(Token.Instance.User, UserDataSource.Load(loginUser.UserId));
                            Token.Instance.UserId = loginUser.UserId;
                            Token.Instance.InitUserContext(loginUser);
                            FormsAuthentication.SetAuthCookie(myUser, false);
                            isSuccess = true;
                        }
                    }
                    else
                    {
                        isSuccess = false;
                    }
Regards,
Art