Exemplo n.º 1
0
    protected void TXTuserId_TextChanged(object sender, EventArgs e)
    {
        TXTuserId.Text = TXTuserId.Text.ToLower();
        decimal cnt = DBHelper.SelectDecimal(Agile.Domain.User.CHECK_IF_USER_EXISTS, DBHelper.mp("id", TXTuserId.Text));

        if (cnt > 0)
        {
            populateUser(TXTuserId.Text);
            PanelEdit.Visible = true;
            PanelAdd.Visible  = false;
        }
        else
        {
            AgileLDAPService ldap = AgileUtils.ASRV();
            LDAPInfo         li   = ldap.GetLDAPInfoByAdId(TXTuserId.Text);
            TXTfName.Text = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(li.FirstName.ToLower());
            TXTlName.Text = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(li.LastName.ToLower());
            if (li.Phone.Length >= 10)
            {
                TXTphone.Text = String.Format("{0:(###) ###-####}", Convert.ToDecimal(li.Phone.Substring(0, 10)));
            }
            TXTemail.Text = li.EMail.ToLower();
        }
        mpeUser.Show();
    }
    public string[] AutoCompleteList(string prefixText, int count)
    {
        string lname = "";
        string fname = "";

        String[] name = prefixText.Split(',');
        if (name.Length == 2)
        {
            lname = name[0];
            fname = name[1].Replace(" ", "");
        }
        else
        {
            lname = name[0];
        }
        AgileLDAPService ldap = AgileUtils.ASRV();

        LDAPInfo[] ldi = ldap.GetLDAPInfoByName(lname, fname);

        List <string> items = new List <string>(ldi.Length);

        foreach (LDAPInfo l in ldi)
        {
            try {
                items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(l.DisplayName, l.AdId.ToLower()));
                if (items.Count == 100)
                {
                    break;
                }
            } catch (Exception) { }
        }

        return(items.ToArray());
    }
Exemplo n.º 3
0
    protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Request.QueryString["key"] == null)
        {
            string authType   = WebConfigurationManager.AppSettings["authType"];
            string userIdType = WebConfigurationManager.AppSettings["userIdType"];
            if (authType.Equals("DEV"))
            {
                Response.Redirect(WebConfigurationManager.AppSettings["SignOnUrlDev"] + userIdType + WebConfigurationManager.AppSettings["SignOnReturn"] + HttpContext.Current.Request.Url.AbsoluteUri);
            }
            else if (Request.Browser.Browser.Equals("IE") && authType.Equals("WINDOWS"))
            {
                Response.Redirect(WebConfigurationManager.AppSettings["SignOnUrlWin"] + userIdType + WebConfigurationManager.AppSettings["SignOnReturn"] + HttpContext.Current.Request.Url.AbsoluteUri);
            }
            else
            {
                Response.Redirect(WebConfigurationManager.AppSettings["SignOnUrlForms"] + userIdType + WebConfigurationManager.AppSettings["SignOnReturn"] + HttpContext.Current.Request.Url.AbsoluteUri);
            }
        }
        else
        {
            string key = Request.QueryString["key"];

            AgileLDAPService asrv   = AgileUtils.ASRV();
            string           userId = asrv.SignOnUserId(key);
            LDAPInfo         l      = new LDAPInfo();

            if (Membership.ValidateUser(userId, "password"))
            {
                FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, userId, DateTime.Now,
                                                                              DateTime.Now.AddMinutes(30), false, userId);
                string     cookiestr = FormsAuthentication.Encrypt(tkt);
                HttpCookie ck        = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
                ck.Path = FormsAuthentication.FormsCookiePath;
                Response.Cookies.Add(ck);

                if (Request["ReturnUrl"] == null)
                {
                    Response.Redirect("~/default.aspx", true);
                }
                else
                {
                    Response.Redirect((String)Request["ReturnUrl"], true);
                }
            }
            else
            {
                Response.Redirect("~/Secure/unauthorized.aspx");
            }
        }
    }