Beispiel #1
0
        public static int AuthenticateUser(string username, string password, string ipAddress,
                                           bool rememberLogin, string preferredLocale, string theme)
        {
            esAuthentication authService = new esAuthentication();

            ConfigureEnterpriseServerProxy(authService, false);

            try
            {
                int authResult = authService.AuthenticateUser(username, password, ipAddress);

                if (authResult < 0)
                {
                    return(authResult);
                }
                else
                {
                    UserInfo user = authService.GetUserByUsernamePassword(username, password, ipAddress);
                    if (user != null)
                    {
                        // issue authentication ticket
                        FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, user.Password, user.Role, rememberLogin);
                        SetAuthTicket(ticket, rememberLogin);

                        CompleteUserLogin(username, rememberLogin, preferredLocale, theme);
                    }

                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public override AuthenticationResult AuthenticateUser(string domain, string username, string password)
        {
            try
            {
                // authentication
                esAuthentication auth = new esAuthentication();
                SetupProxy(auth);

                int result = auth.AuthenticateUser(username, password, "");

                if (result == -109)
                {
                    return(AuthenticationResult.WrongUsername);
                }
                else if (result == -110)
                {
                    return(AuthenticationResult.WrongPassword);
                }

                // load user account
                UserInfo user = auth.GetUserByUsernamePassword(username, password, "");
                if (user == null)
                {
                    return(AuthenticationResult.WrongUsername);
                }

                // get all packages
                esPackages packagesProxy = new esPackages();
                SetupProxy(packagesProxy, username, password);
                esStatisticsServers statsServers = new esStatisticsServers();
                SetupProxy(statsServers, username, password);
                PackageInfo[] packages = packagesProxy.GetMyPackages(user.UserId);

                // load all statistics sites from all packages
                foreach (PackageInfo package in packages)
                {
                    StatsSite[] sites = statsServers.GetStatisticsSites(package.PackageId, false);

                    foreach (StatsSite site in sites)
                    {
                        if (String.Compare(site.Name, domain, true) == 0)
                        {
                            return(AuthenticationResult.OK);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Web.HttpContext.Current.Response.Write(ex.ToString());
            }

            return(AuthenticationResult.DomainNotFound);
        }
Beispiel #3
0
        public static int AuthenticateUser(string username, string password, string ipAddress,
                                           bool rememberLogin, string preferredLocale, string theme)
        {
            esAuthentication authService = new esAuthentication();

            ConfigureEnterpriseServerProxy(authService, false);

            string passwordSH = SHA1(password);

            try
            {
                int authResult = authService.AuthenticateUser(username, passwordSH, ipAddress);

                if (authResult < 0)
                {
                    return(authResult);
                }
                else
                {
                    UserInfo user = authService.GetUserByUsernamePassword(username, passwordSH, ipAddress);
                    if (user != null)
                    {
                        if (IsRoleAllowedToLogin(user.Role))
                        {
                            // issue authentication ticket
                            FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, password, user.Role, rememberLogin);
                            SetAuthTicket(ticket, rememberLogin);

                            CompleteUserLogin(username, rememberLogin, preferredLocale, theme);
                        }
                        else
                        {
                            return(BusinessErrorCodes.ERROR_USER_ACCOUNT_ROLE_NOT_ALLOWED);
                        }
                    }

                    return(authResult);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }