private User buildUser(DataRow row = null)
        {
            User user = new User();

            if (row == null)
            {
                var ADuser = ActiveDirectoryHelper.getUserByLogin(txtUsername.Text);
                user = new User()
                {
                    ID        = ADuser.Properties["distinguishedName"].Value.ToString(),
                    LoginID   = txtUsername.Text,
                    FirstName = ADuser.Properties["givenName"].Value.ToString(),
                    LastName  = ADuser.Properties["SN"].Value.ToString(),
                    IsAdmin   = false
                };
            }
            else
            {
                user = new User()
                {
                    ID        = row["ID"].ToString(),
                    LoginID   = row["LoginID"].ToString(),
                    FirstName = row["FirstName"].ToString(),
                    LastName  = row["LastName"].ToString(),
                    IsAdmin   = true
                };
            }

            return(user);
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string serverError = "";
            bool   ua          = ActiveDirectoryHelper.AuthenticeUser(txtUsername.Text, txtPassword.Text, ref serverError);

            DataTable user = new DataTable();

            if (!ua)
            {
                user = getUserInformation(txtUsername.Text, txtPassword.Text);
            }

            if (ua || user.Rows.Count > 0)
            {
                User userSession = buildUser(user.Rows.Count > 0 ? user.Rows[0] : null);

                Session["User"] = userSession;

                Response.Redirect("~/Requests.aspx");
            }
            else
            {
                pnlError.Visible = true;
                lblError.Text    = String.IsNullOrEmpty(serverError) ? "Invalid Username or password" : serverError;
                //pnlFailedLogin.Update();
            }

            //Response.Redirect("~/Home.aspx");
        }
 protected void btnSubmitDomain_OnClick(object sender, EventArgs e)
 {
     new DBConnector().updateSettingValueByName("DOMAIN", txtDomain.Text);
     txtDomain.Text   = ActiveDirectoryHelper.getCurrentDomain();
     lblDomain.Text   = "Current Domain: <b>" + txtDomain.Text + "</b>";
     pnlError.Visible = false;
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         txtDomain.Text = ActiveDirectoryHelper.getCurrentDomain();
         lblDomain.Text = "Current Domain: <b>" + txtDomain.Text + "</b>";
     }
 }
Exemple #5
0
        protected void populatDropDowns()
        {
            ddlLicHolder.Items.Clear();
            ddlHolderManager.Items.Clear();
            ddlLicHolder.SelectedIndex = ddlHolderManager.SelectedIndex = 0;
            ddlLicHolder.Items.Add("");
            ddlLicHolder.Items[0].Value = "";
            ddlHolderManager.Items.Add("");
            ddlHolderManager.Items[0].Value = "";

            if (VSActiveUsers.Count > 0)
            {
                foreach (var item in VSActiveUsers)
                {
                    ListItem input = new ListItem(item.Item1, item.Item2);
                    ddlLicHolder.Items.Add(input);
                    ddlHolderManager.Items.Add(input);
                }
            }
            else
            {
                var everyone = ActiveDirectoryHelper.GetAdUsers();
                //var anyone = ActiveDirectoryHelper.getAllUsersOnDomain();
                var list = new List <Tuple <String, String, String> >();

                foreach (var item in everyone)
                {
                    ListItem input = new ListItem(item.Item1, item.Item3);
                    ddlLicHolder.Items.Add(input);
                    ddlHolderManager.Items.Add(input);
                    list.Add(item);
                }

                VSActiveUsers = list;
            }
        }