Ejemplo n.º 1
0
        private void FillDomains()
        {
            ddlDomains.Items.Clear();

            if (UserContext.Current != null)
            {
                var list = EmailSuffixProvider.GetEmailSuffixesList(UserContext.Current.OrganizationId);

                if (list != null)
                {
                    foreach (string domain in list)
                    {
                        ddlDomains.Items.Add(new ListItem()
                        {
                            Text = domain, Value = domain
                        });
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void EditForm_DataBound(object sender, EventArgs e)
        {
            MonthList.Items.Add(new RadComboBoxItem(String.Empty, "0"));
            DateTime month = DateTime.MinValue;

            for (int i = 0; i < 12; i++)
            {
                DateTime date = month.AddMonths(i);
                MonthList.Items.Add(new RadComboBoxItem(date.ToString("MMMM", CultureInfo.CurrentCulture), date.Month.ToString(CultureInfo.InvariantCulture)));
            }

            DayList.Items.Add(new RadComboBoxItem(String.Empty, "0"));
            for (int i = 1; i < 32; i++)
            {
                DayList.Items.Add(new RadComboBoxItem(i.ToString(CultureInfo.InvariantCulture), i.ToString(CultureInfo.InvariantCulture)));
            }

            WeekStartsDayList.Items.Add(new RadComboBoxItem());
            WeekStartsDayList.Items.Add(new RadComboBoxItem(Resources.OrganizationProfileControl_WeekStartsDayList_Sunday, ((int)FirstDayOfWeek.Sunday).ToString(CultureInfo.InvariantCulture)));
            WeekStartsDayList.Items.Add(new RadComboBoxItem(Resources.OrganizationProfileControl_WeekStartsDayList_Monday, ((int)FirstDayOfWeek.Monday).ToString(CultureInfo.InvariantCulture)));

            UserContext user = UserContext.Current;

            Organization org = user.Organization;

            if (org.FiscalYearStartMonth.HasValue)
            {
                MonthList.SelectedValue = org.FiscalYearStartMonth.Value.ToString(CultureInfo.InvariantCulture);
            }
            if (org.FiscalYearStartDay.HasValue)
            {
                DayList.SelectedValue = org.FiscalYearStartDay.Value.ToString(CultureInfo.InvariantCulture);
            }
            if (org.WeekStartsDay.HasValue)
            {
                WeekStartsDayList.SelectedValue = (org.WeekStartsDay.Value).ToString(CultureInfo.InvariantCulture);
            }

            EmailSuffixes.Text = EmailSuffixProvider.GetEmailSuffixName(user.OrganizationId);
        }
Ejemplo n.º 3
0
        protected void EditForm_DataBound(object sender, EventArgs e)
        {
            string workingDays = string.Empty;
            string timeZoneId  = null;
            string timeFormat  = null;
            string dateFormat  = null;

            if (EditForm.DataItem != null)
            {
                Instance inst = (Instance)EditForm.DataItem;

                workingDays = inst.WorkingDays;
                timeZoneId  = inst.TimeZoneId;
                timeFormat  = inst.TimeFormat.ToString(CultureInfo.InvariantCulture);
                dateFormat  = inst.DateFormat.ToString(CultureInfo.InvariantCulture);

                EmailSuffixes.Text = EmailSuffixProvider.GetEmailSuffixNameByInstanceId(inst.InstanceId);
            }

            BaseControl.WorkingDaysListDataBind(WorkingDays, workingDays);
            BaseControl.TimeZoneListDataBind(TimeZoneList, timeZoneId, true);
            BaseControl.TimeFormatListDataBind(TimeFormatList, timeFormat, true);
            BaseControl.DateFormatListDataBind(DateFormatList, dateFormat, true);
        }
Ejemplo n.º 4
0
        protected void btnSaveToken_Click(object sender, EventArgs e)
        {
            trFormError.Visible     = false;
            mvStep1.ActiveViewIndex = -1;
            mvStep2.ActiveViewIndex = -1;
            try
            {
                Service service = new Service(AppsNameTable.GAppsService, "sherpadesk");
                string  token   = string.Empty;

                if (trGoogleDomain.Visible)
                {
                    string      googleDomain = txtGoogleDomain.Text;
                    AppsService appService   = new AppsService(googleDomain, txtGoogleEmail.Text, txtGooglePassword.Text);
                    GroupFeed   groups       = appService.Groups.RetrieveAllGroups();

                    EmailSuffixProvider.InsertEmailSuffixName(UserContext.Current.OrganizationId, null, ref googleDomain);
                    FillDomains();
                }

                service.setUserCredentials(txtGoogleEmail.Text, txtGooglePassword.Text);
                token = service.QueryClientLoginToken();
                OrganizationProvider.UpdateOrganizationGoogleAdminAuthToken(UserContext.Current.OrganizationId, token);
                mvConnectionSettings.SetActiveView(vwToken);
            }
            catch (AppsException a)
            {
                lblFromError.Text   = string.Format(CultureInfo.CurrentCulture, Resources.GoogleIntegrationControl_GoogleAppsError_Text, a.ErrorCode, a.InvalidInput, a.Reason);
                trFormError.Visible = true;
            }
            catch (Exception ex)
            {
                lblFromError.Text   = ex.Message;
                trFormError.Visible = true;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Occurs when the login button is clicked.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains no event data.</param>
        protected void LogOnButton_Click(object sender, EventArgs e)
        {
            string loginName = LoginTextBox.Text;

            try
            {
                if (LoginProvider.Current.Authenticate(loginName, PasswordTextBox.Text, true, true, this.OrganizationId, this.InstanceId))
                {
                    if (!string.IsNullOrEmpty(m_EmailToLink))
                    {
                        if (!EmailProvider.IsEmailExists(m_EmailToLink))
                        {
                            LinkEmailLabel.Text = string.Format(CultureInfo.InvariantCulture, Resources.LogOnControl_LinkEmailLabel_Text, loginName, m_EmailToLink);

                            LinkEmailPanel.Visible = true;
                            FormTable.Visible      = false;
                            if (LogoImagePanel != null)
                            {
                                LogoImagePanel.Visible = false;
                            }

                            m_MainContainerHeight = 150;
                        }
                        else
                        {
                            this.RedirectAfterLogOn();
                        }
                    }
                    else
                    {
                        this.RedirectAfterLogOn();
                    }
                }
            }
            catch (AuthenticationException ex)
            {
                string message = ex.Message;

                if (FrameworkConfiguration.Current.WebApplication.Integration.Google.Enabled)
                {
                    IList domains = null;

                    if (string.Compare(ex.Message, FrameworkConfiguration.Current.WebApplication.Login.FailureText, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        Organization org = OrganizationProvider.GetOrganization(this.OrganizationId);

                        if (org == null)
                        {
                            OrganizationCollection orgs = LoginProvider.Current.GetOrganizationsByLoginName(loginName);
                            if ((orgs != null) && (orgs.Count > 0))
                            {
                                org = orgs[0];
                            }
                        }

                        if (org != null)
                        {
                            if (SettingProvider.OrganizationProviderIsGoogle(org.OrganizationId))
                            {
                                domains = EmailSuffixProvider.GetEmailSuffixesList(org.OrganizationId);
                            }
                        }
                    }

                    if (domains == null)
                    {
                        domains = FrameworkConfiguration.Current.WebApplication.Integration.Google.MailDomains;
                    }

                    if (domains != null)
                    {
                        foreach (string domain in domains)
                        {
                            if (loginName.IndexOf(domain, StringComparison.OrdinalIgnoreCase) != -1)
                            {
                                message = Resources.LoginElement_GoogleFailureText;
                                break;
                            }
                        }
                    }
                }

                this.ShowErrorMessage(message);
            }
        }
Ejemplo n.º 6
0
        private void Authenticate()
        {
            string password           = Request.QueryString["p"];
            string isPersistentString = Request.QueryString["cp"];
            string loginName          = this.LoginName;
            bool   isPersistent       = true;

            if (isPersistentString != null)
            {
                if (!Boolean.TryParse(isPersistentString, out isPersistent))
                {
                    isPersistent = false;
                }
            }

            Guid organizationId     = this.OrganizationId;
            Guid instanceId         = this.InstanceId;
            bool isCustomUrlEnabled = FrameworkConfiguration.Current.WebApplication.CustomUrl.Enabled;

            if (isCustomUrlEnabled)
            {
                if (organizationId == Guid.Empty)
                {
                    string host = Request.Url.Host;
                    if (!CustomUrlProvider.IsDefaultVanityUrl(host))
                    {
                        CustomUrlProvider.ParseHost(host, ref organizationId, ref instanceId);
                    }
                }
                else if (!GoogleProvider.IsGoogleProviderRequest(Request))
                {
                    this.VerifyVanityUrl(organizationId, instanceId);
                }
            }

            if (!(string.IsNullOrEmpty(loginName) || string.IsNullOrEmpty(password) || (organizationId == Guid.Empty)))
            {
                if (!isCustomUrlEnabled)
                {
                    LoginProvider loginProvider = new LoginProvider();
                    loginProvider.SignOut(true, false);
                }

                try
                {
                    LoginProvider.Current.Authenticate(loginName, Support.Decrypt(password), false, isPersistent, organizationId, instanceId);

                    this.RedirectAfterLogOn();
                }
                catch (AuthenticationException ex)
                {
                    ShowErrorMessage(ex.Message);
                }
            }
            else
            {
                if (GoogleProvider.IsGoogleProviderRequest(Request))
                {
                    try
                    {
                        string accessToken = GoogleProvider.ProcessAuthorization(this.Context, ref organizationId, ref instanceId);

                        string firstName = null;
                        string lastName  = null;
                        GoogleProvider.GetUserProfile(accessToken, out loginName, out firstName, out lastName);
                    }
                    catch (AuthenticationException ex)
                    {
                        ShowErrorMessage(ex.Message);
                    }

                    if (!string.IsNullOrEmpty(loginName))
                    {
                        m_EmailToLink = loginName;

                        string message = null;

                        try
                        {
                            string domain = GoogleProvider.GetDomain(Request);
                            if (!string.IsNullOrEmpty(domain))
                            {
                                EmailSuffixProvider.ParseEmailSuffixName(domain, ref organizationId, ref instanceId);
                            }

                            if (LoginProvider.Current.Authenticate(loginName, null, false, true, organizationId, instanceId))
                            {
                                this.RedirectAfterLogOn();
                            }
                        }
                        catch (AuthenticationException ex)
                        {
                            message = ex.Message;
                        }

                        if (!string.IsNullOrEmpty(message))
                        {
                            if (LoginProvider.Current.GetLogin(loginName) == null)
                            {
                                message = string.Format(CultureInfo.InvariantCulture, Resources.UserContext_ErrorMessage_YourAccountIsNotFound, loginName);
                            }
                        }

                        if (!string.IsNullOrEmpty(message))
                        {
                            this.ShowErrorMessage(message);

                            this.EnableCustomHandling = false;
                        }
                    }
                }
            }
        }