Пример #1
0
    public void Create(WDSUser user)
    {
        try
        {
            using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
            {
                NpgsqlCommand cmd = new NpgsqlCommand("users_create", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new NpgsqlParameter("@userName", user.Name));
                cmd.Parameters.Add(new NpgsqlParameter("@userPwd", user.CreatePasswordHash(user.Password, user.Salt)));
                cmd.Parameters.Add(new NpgsqlParameter("@userSalt", user.Salt));
                cmd.Parameters.Add(new NpgsqlParameter("@userMembership", user.Membership));
                cmd.Parameters.Add(new NpgsqlParameter("@groupManagement", user.GroupManagement));
                cmd.Parameters.Add(new NpgsqlParameter("@ondAccess", user.OndAccess));
                cmd.Parameters.Add(new NpgsqlParameter("@debugAccess", user.DebugAccess));
                cmd.Parameters.Add(new NpgsqlParameter("@diagAccess", user.DiagAccess));
                conn.Open();
                Utility.Message = cmd.ExecuteScalar() as string;

                if (Utility.Message.Contains("Successfully"))
                {
                    History history = new History();
                    history.Event  = "Create";
                    history.Type   = "User";
                    history.TypeID = user.GetID(user.Name);
                    history.CreateEvent(history);
                }
            }
        }
        catch (Exception ex)
        {
            Utility.Message = "Could Not Create User.  Check The Exception Log For More Info";
            Logger.Log(ex.ToString());
        }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Utility utility = new Utility();
        WDSUser user    = new WDSUser();

        user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
        user    = user.Read(user);

        if (utility.GetSettings("On Demand") == "Disabled")
        {
            secure.Visible    = false;
            secureMsg.Text    = "On Demand Mode Has Been Globally Disabled";
            secureMsg.Visible = true;
        }
        else if (user.OndAccess == "0")
        {
            secure.Visible    = false;
            secureMsg.Text    = "On Demand Mode Has Been Disabled For This Account";
            secureMsg.Visible = true;
        }
        else
        {
            secure.Visible    = true;
            secureMsg.Visible = false;
        }
        if (!IsPostBack)
        {
            ddlImage.DataSource = Utility.PopulateImagesDdl();
            ddlImage.DataBind();
            ddlImage.Items.Insert(0, "Select Image");
        }
    }
Пример #3
0
    public DataTable TableForUser(string search)
    {
        Host    host = new Host();
        WDSUser user = new WDSUser();

        user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
        user    = user.Read(user);
        DataTable table = new DataTable();

        if (!string.IsNullOrEmpty(user.GroupManagement))
        {
            List <string> listManagementGroups = user.GroupManagement.Split(' ').ToList <string>();



            foreach (string id in listManagementGroups)
            {
                Group mgmtgroup = new Group();
                mgmtgroup.ID = id;
                mgmtgroup    = mgmtgroup.Read(mgmtgroup);

                table.Merge(host.SearchLimited(search, mgmtgroup.Name));
            }

            if (table.Rows.Count > 0)
            {
                DataView dtview = new DataView(table);
                dtview.Sort = "hostName asc";
                table       = dtview.ToTable();
            }
        }

        return(table);
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Utility utility = new Utility();
        WDSUser user = new WDSUser();
        user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
        user = user.Read(user);

        if (utility.GetSettings("On Demand") == "Disabled")
        {
            secure.Visible = false;
            secureMsg.Text = "On Demand Mode Has Been Globally Disabled";
            secureMsg.Visible = true;
        }
        else if (user.OndAccess == "0")
        {
             secure.Visible = false;
             secureMsg.Text = "On Demand Mode Has Been Disabled For This Account";
             secureMsg.Visible = true;
        }
        else
        {
             secure.Visible = true;
             secureMsg.Visible = false;
        }
        if (!IsPostBack)
        {
            ddlImage.DataSource = Utility.PopulateImagesDdl();
            ddlImage.DataBind();
            ddlImage.Items.Insert(0, "Select Image");
        }
    }
Пример #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!Master.IsInMembership("Administrator"))
         {
             WDSUser wdsuser = new WDSUser();
             string tmpUserID = wdsuser.GetID(HttpContext.Current.User.Identity.Name);
             if(tmpUserID != Request.QueryString["userid"] as string)
                 Response.Redirect("~/views/dashboard/dash.aspx?access=denied");
         }
     }
 }
Пример #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!Master.IsInMembership("Administrator"))
         {
             WDSUser wdsuser   = new WDSUser();
             string  tmpUserID = wdsuser.GetID(HttpContext.Current.User.Identity.Name);
             if (tmpUserID != Request.QueryString["userid"] as string)
             {
                 Response.Redirect("~/views/dashboard/dash.aspx?access=denied");
             }
         }
     }
 }
Пример #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!Master.IsInMembership("Administrator"))
         {
             WDSUser wdsuser = new WDSUser();
             string  userID  = wdsuser.GetID(HttpContext.Current.User.Identity.Name);
             if (string.IsNullOrEmpty(userID)) //Fix for clicking logout button when on users page
             {
                 Response.Redirect("~/");
             }
             else
             {
                 Response.Redirect("~/views/users/resetpass.aspx?userid=" + userID);
             }
         }
         PopulateGrid();
     }
 }
Пример #8
0
    public DataTable TableForUser(string search)
    {
        Group   group = new Group();
        WDSUser user  = new WDSUser();

        user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
        user    = user.Read(user);
        DataTable table = group.Search(search);


        if (!string.IsNullOrEmpty(user.GroupManagement))
        {
            List <string> listManagementGroups = user.GroupManagement.Split(' ').ToList <string>();



            List <string> groupNames = new List <string>();
            foreach (string id in listManagementGroups)
            {
                group.ID = id;
                group    = group.Read(group);
                groupNames.Add(group.Name);
            }
            foreach (DataRow row in table.Rows)
            {
                if (!groupNames.Contains(row["groupname"].ToString()))
                {
                    row.Delete();
                }
            }
        }
        else
        {
            foreach (DataRow row in table.Rows)
            {
                row.Delete();
            }
        }

        return(table);
    }
Пример #9
0
    protected void edit_page()
    {
        Master.Msgbox(Utility.Message);
        ddlHostImage.DataSource = Utility.PopulateImagesDdl();
        ddlHostImage.DataBind();
        ddlHostImage.Items.Insert(0, "Select Image");

        ddlHostGroup.DataSource = Utility.PopulateGroupsDdl();
        ddlHostGroup.DataBind();
        ddlHostGroup.Items.Insert(0, "");

        lbScripts.DataSource = Utility.GetScripts();
        lbScripts.DataBind();

        if (Master.IsInMembership("User"))
        {
            WDSUser user = new WDSUser();
            user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
            user = user.Read(user);
            List<string> listManagementGroups = user.GroupManagement.Split(' ').ToList<string>();

            List<string> allowedGroups = new List<string>();

            foreach (string id in listManagementGroups)
            {
                Group mgmtgroup = new Group();
                mgmtgroup.ID = id;
                mgmtgroup = mgmtgroup.Read(mgmtgroup);

                foreach (ListItem item in ddlHostGroup.Items)
                {
                    if (item.Value == mgmtgroup.Name)
                        allowedGroups.Add(mgmtgroup.Name);
                }
            }

            bool isAuthorized = false;
            foreach (string aGroup in allowedGroups)
            {
                if (host.Group == aGroup)
                {
                    isAuthorized = true;
                    break;
                }
            }

            if (!isAuthorized)
                Response.Redirect("~/views/dashboard/dash.aspx?access=denied");

            ddlHostGroup.DataSource = allowedGroups;
            ddlHostGroup.DataBind();
            ddlHostGroup.Items.Insert(0, "");
        }

        ddlHostKernel.DataSource = Utility.GetKernels();
        ddlHostKernel.DataBind();
        ddlHostKernel.Items.Insert(0, "Select Kernel");

        ddlHostBootImage.DataSource = Utility.GetBootImages();
        ddlHostBootImage.DataBind();
        ddlHostBootImage.Items.Insert(0, "Select Boot Image");

        txtHostName.Text = host.Name;
        txtHostMac.Text = host.Mac;
        ddlHostImage.Text = host.Image;
        ddlHostGroup.Text = host.Group;
        txtHostDesc.Text = host.Description;
        ddlHostKernel.Text = host.Kernel;
        ddlHostBootImage.Text = host.BootImage;
        txtHostArguments.Text = host.Args;

        if (!string.IsNullOrEmpty(host.Scripts))
        {
            List<string> listhostScripts = host.Scripts.Split(',').ToList<string>();
            foreach (ListItem item in lbScripts.Items)
                foreach (var script in listhostScripts)
                    if (item.Value == script)
                        item.Selected = true;
        }
    }
Пример #10
0
    public void Create(WDSUser user)
    {
        try
        {
            using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
            {
                NpgsqlCommand cmd = new NpgsqlCommand("users_create", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new NpgsqlParameter("@userName", user.Name));
                cmd.Parameters.Add(new NpgsqlParameter("@userPwd", user.CreatePasswordHash(user.Password, user.Salt)));
                cmd.Parameters.Add(new NpgsqlParameter("@userSalt", user.Salt));
                cmd.Parameters.Add(new NpgsqlParameter("@userMembership", user.Membership));
                cmd.Parameters.Add(new NpgsqlParameter("@groupManagement", user.GroupManagement));
                cmd.Parameters.Add(new NpgsqlParameter("@ondAccess", user.OndAccess));
                cmd.Parameters.Add(new NpgsqlParameter("@debugAccess", user.DebugAccess));
                cmd.Parameters.Add(new NpgsqlParameter("@diagAccess", user.DiagAccess));
                conn.Open();
                Utility.Message = cmd.ExecuteScalar() as string;

                if (Utility.Message.Contains("Successfully"))
                {
                    History history = new History();
                    history.Event = "Create";
                    history.Type = "User";
                    history.TypeID = user.GetID(user.Name);
                    history.CreateEvent(history);
                }
            }
        }
        catch (Exception ex)
        {
            Utility.Message = "Could Not Create User.  Check The Exception Log For More Info";
            Logger.Log(ex.ToString());
        }
    }
Пример #11
0
        public void consolelogin()
        {
            History history = new History();
            Utility settings = new Utility();
            HttpContext postedContext = HttpContext.Current;
            HttpFileCollection Files = postedContext.Request.Files;

            string serverKey = settings.Decode((string)postedContext.Request.Form["serverKey"]);
            history.IP = settings.Decode((string)postedContext.Request.Form["clientIP"]);

            if (serverKey == settings.GetSettings("Server Key"))
            {
                 string username = settings.Decode((string)postedContext.Request.Form["username"]);
                 string password = settings.Decode((string)postedContext.Request.Form["password"]);
                 string task = settings.Decode((string)postedContext.Request.Form["task"]);

                 if (settings.UserLogin(username, password))
                 {
                      WDSUser wdsuser = new WDSUser();
                      string userID = wdsuser.GetID(username);
                      wdsuser.ID = userID;
                      wdsuser = wdsuser.Read(wdsuser);

                      if (task == "ond" && wdsuser.OndAccess == "1")
                      {
                           HttpContext.Current.Response.Write("true," + userID);
                           history.Event = "Successful Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.TypeID = userID;
                           history.Notes = "";
                           history.CreateEvent(history);
                      }
                      else if (task == "debug" && wdsuser.DebugAccess == "1")
                      {
                           HttpContext.Current.Response.Write("true," + userID);
                           history.Event = "Successful Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.TypeID = userID;
                           history.Notes = "";
                           history.CreateEvent(history);
                      }
                      else if (task == "diag" && wdsuser.DiagAccess == "1")
                      {
                           HttpContext.Current.Response.Write("true," + userID);
                           history.Event = "Successful Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.TypeID = userID;
                           history.Notes = "";
                           history.CreateEvent(history);
                      }
                      else
                      {
                           HttpContext.Current.Response.Write("false");
                           history.Event = "Failed Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.Notes = password;
                           history.CreateEvent(history);
                      }
                 }
                 else if (!string.IsNullOrEmpty(settings.GetSettings("AD Login Domain")))
                 {

                      try
                      {
                           PrincipalContext context = new PrincipalContext(ContextType.Domain, settings.GetSettings("AD Login Domain"), username, password);
                           UserPrincipal user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, username);
                           if (user != null)
                           {
                                WDSUser wdsuser = new WDSUser();
                                string userID = wdsuser.GetID(username);
                                wdsuser.ID = userID;
                                wdsuser = wdsuser.Read(wdsuser);

                                if (task == "ond" && wdsuser.OndAccess == "1")
                                {
                                     HttpContext.Current.Response.Write("true," + userID);
                                     history.Event = "Successful Console Login";
                                     history.Type = "User";
                                     history.EventUser = username;
                                     history.TypeID = userID;
                                     history.Notes = "";
                                     history.CreateEvent(history);
                                }
                                else if (task == "debug" && wdsuser.DebugAccess == "1")
                                {
                                     HttpContext.Current.Response.Write("true," + userID);
                                     history.Event = "Successful Console Login";
                                     history.Type = "User";
                                     history.EventUser = username;
                                     history.TypeID = userID;
                                     history.Notes = "";
                                     history.CreateEvent(history);
                                }
                                else if (task == "diag" && wdsuser.DiagAccess == "1")
                                {
                                     HttpContext.Current.Response.Write("true," + userID);
                                     history.Event = "Successful Console Login";
                                     history.Type = "User";
                                     history.EventUser = username;
                                     history.TypeID = userID;
                                     history.Notes = "";
                                     history.CreateEvent(history);
                                }
                                else
                                {
                                     HttpContext.Current.Response.Write("false");
                                     history.Event = "Failed Console Login";
                                     history.Type = "User";
                                     history.EventUser = username;
                                     history.Notes = password;
                                     history.CreateEvent(history);
                                }
                           }

                      }
                      catch
                      {
                           HttpContext.Current.Response.Write("false");
                           history.Event = "Failed Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.Notes = password;
                           history.CreateEvent(history);
                      }
                 }
                 else
                 {
                      HttpContext.Current.Response.Write("false");
                      history.Event = "Failed Console Login";
                      history.Type = "User";
                      history.EventUser = username;
                      history.Notes = password;
                      history.CreateEvent(history);
                 }
            }

            else
            {
                 Logger.Log("Incorrect Key For Client Login Was Provided");
            }
        }
Пример #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!Master.IsInMembership("Administrator"))
         {
             WDSUser wdsuser = new WDSUser();
             string userID = wdsuser.GetID(HttpContext.Current.User.Identity.Name);
              if(string.IsNullOrEmpty(userID)) //Fix for clicking logout button when on users page
                  Response.Redirect("~/");
              else
             Response.Redirect("~/views/users/resetpass.aspx?userid=" + userID);
         }
         PopulateGrid();
     }
 }
Пример #13
0
    protected void CrucibleLogin_Authenticate(object sender, AuthenticateEventArgs e)
    {
        Utility login   = new Utility();
        History history = new History();
        WDSUser wdsuser = new WDSUser();

        string loginDomain = login.GetSettings("AD Login Domain");

        history.Type      = "User";
        history.IP        = GetIP();
        history.EventUser = CrucibleLogin.UserName;
        wdsuser.ID        = wdsuser.GetID(CrucibleLogin.UserName);
        history.TypeID    = wdsuser.ID;

        if (string.IsNullOrEmpty(wdsuser.ID))
        {
            history.Event    = "Failed Login";
            e.Authenticated  = false;
            lblError.Visible = true;
        }

        else
        {
            if (string.IsNullOrEmpty(loginDomain))
            {
                bool result = login.UserLogin(CrucibleLogin.UserName, CrucibleLogin.Password);
                if ((result))
                {
                    history.Event   = "Successful Login";
                    e.Authenticated = true;
                }
                else
                {
                    history.Event    = "Failed Login";
                    e.Authenticated  = false;
                    lblError.Visible = true;
                }
            }
            else
            {
                try
                {
                    PrincipalContext context = new PrincipalContext(ContextType.Domain, loginDomain, CrucibleLogin.UserName, CrucibleLogin.Password);
                    UserPrincipal    user    = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, CrucibleLogin.UserName);
                    if (user != null)
                    {
                        history.Event   = "Successful Login";
                        e.Authenticated = true;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message);
                    bool result = login.UserLogin(CrucibleLogin.UserName, CrucibleLogin.Password);
                    if ((result))
                    {
                        history.Event   = "Successful Login";
                        e.Authenticated = true;
                    }
                    else
                    {
                        history.Event    = "Failed Login";
                        e.Authenticated  = false;
                        lblError.Visible = true;
                    }
                }
            }
        }

        history.CreateEvent(history);
    }
Пример #14
0
    protected void edit_page()
    {
        Master.Msgbox(Utility.Message);
        ddlHostImage.DataSource = Utility.PopulateImagesDdl();
        ddlHostImage.DataBind();
        ddlHostImage.Items.Insert(0, "Select Image");

        ddlHostGroup.DataSource = Utility.PopulateGroupsDdl();
        ddlHostGroup.DataBind();
        ddlHostGroup.Items.Insert(0, "");

        lbScripts.DataSource = Utility.GetScripts();
        lbScripts.DataBind();



        if (Master.IsInMembership("User"))
        {
            WDSUser user = new WDSUser();
            user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
            user    = user.Read(user);
            List <string> listManagementGroups = user.GroupManagement.Split(' ').ToList <string>();

            List <string> allowedGroups = new List <string>();

            foreach (string id in listManagementGroups)
            {
                Group mgmtgroup = new Group();
                mgmtgroup.ID = id;
                mgmtgroup    = mgmtgroup.Read(mgmtgroup);

                foreach (ListItem item in ddlHostGroup.Items)
                {
                    if (item.Value == mgmtgroup.Name)
                    {
                        allowedGroups.Add(mgmtgroup.Name);
                    }
                }
            }

            bool isAuthorized = false;
            foreach (string aGroup in allowedGroups)
            {
                if (host.Group == aGroup)
                {
                    isAuthorized = true;
                    break;
                }
            }

            if (!isAuthorized)
            {
                Response.Redirect("~/views/dashboard/dash.aspx?access=denied");
            }

            ddlHostGroup.DataSource = allowedGroups;
            ddlHostGroup.DataBind();
            ddlHostGroup.Items.Insert(0, "");
        }

        ddlHostKernel.DataSource = Utility.GetKernels();
        ddlHostKernel.DataBind();
        ddlHostKernel.Items.Insert(0, "Select Kernel");

        ddlHostBootImage.DataSource = Utility.GetBootImages();
        ddlHostBootImage.DataBind();
        ddlHostBootImage.Items.Insert(0, "Select Boot Image");

        txtHostName.Text      = host.Name;
        txtHostMac.Text       = host.Mac;
        ddlHostImage.Text     = host.Image;
        ddlHostGroup.Text     = host.Group;
        txtHostDesc.Text      = host.Description;
        ddlHostKernel.Text    = host.Kernel;
        ddlHostBootImage.Text = host.BootImage;
        txtHostArguments.Text = host.Args;

        if (!string.IsNullOrEmpty(host.Scripts))
        {
            List <string> listhostScripts = host.Scripts.Split(',').ToList <string>();
            foreach (ListItem item in lbScripts.Items)
            {
                foreach (var script in listhostScripts)
                {
                    if (item.Value == script)
                    {
                        item.Selected = true;
                    }
                }
            }
        }
    }
Пример #15
0
    public DataTable TableForUser(string search)
    {
        Host host = new Host();
        WDSUser user = new WDSUser();
        user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
        user = user.Read(user);
        DataTable table = new DataTable();

        if (!string.IsNullOrEmpty(user.GroupManagement))
        {
             List<string> listManagementGroups = user.GroupManagement.Split(' ').ToList<string>();

             foreach (string id in listManagementGroups)
             {
                  Group mgmtgroup = new Group();
                  mgmtgroup.ID = id;
                  mgmtgroup = mgmtgroup.Read(mgmtgroup);

                  table.Merge(host.SearchLimited(search, mgmtgroup.Name));
             }

             if (table.Rows.Count > 0)
             {
                  DataView dtview = new DataView(table);
                  dtview.Sort = "hostName asc";
                  table = dtview.ToTable();
             }
        }

        return table;
    }
Пример #16
0
    protected void CrucibleLogin_Authenticate(object sender, AuthenticateEventArgs e)
    {
        Utility login = new Utility();
        History history = new History();
        WDSUser wdsuser = new WDSUser();

        string loginDomain = login.GetSettings("AD Login Domain");
        history.Type = "User";
        history.IP = GetIP();
        history.EventUser = CrucibleLogin.UserName;
        wdsuser.ID = wdsuser.GetID(CrucibleLogin.UserName);
        history.TypeID = wdsuser.ID;

        if (string.IsNullOrEmpty(wdsuser.ID))
        {
            history.Event = "Failed Login";
            e.Authenticated = false;
            lblError.Visible = true;
        }

        else
        {
            if (string.IsNullOrEmpty(loginDomain))
            {
                bool result = login.UserLogin(CrucibleLogin.UserName, CrucibleLogin.Password);
                if ((result))
                {
                    history.Event = "Successful Login";
                    e.Authenticated = true;
                }
                else
                {
                    history.Event = "Failed Login";
                    e.Authenticated = false;
                    lblError.Visible = true;
                }

            }
            else
            {
                try
                {
                    PrincipalContext context = new PrincipalContext(ContextType.Domain, loginDomain, CrucibleLogin.UserName, CrucibleLogin.Password);
                    UserPrincipal user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, CrucibleLogin.UserName);
                    if (user != null)
                    {
                        history.Event = "Successful Login";
                        e.Authenticated = true;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message);
                    bool result = login.UserLogin(CrucibleLogin.UserName, CrucibleLogin.Password);
                    if ((result))
                    {
                        history.Event = "Successful Login";
                        e.Authenticated = true;
                    }
                    else
                    {
                        history.Event = "Failed Login";
                        e.Authenticated = false;
                        lblError.Visible = true;
                    }
                }
            }
        }

        history.CreateEvent(history);
    }
Пример #17
0
    protected void edit_page()
    {
        Master.Msgbox(Utility.Message);

        if (Master.IsInMembership("User"))
        {
            WDSUser user = new WDSUser();
            user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
            user = user.Read(user);
            List<string> listManagementGroups = user.GroupManagement.Split(' ').ToList<string>();

            bool isAuthorized = false;
            foreach (string id in listManagementGroups)
            {
                if (group.ID == id)
                {
                    isAuthorized = true;
                    break;
                }
            }

            if (!isAuthorized)
                Response.Redirect("~/views/dashboard/dash.aspx?access=denied");
        }

        ddlGroupImage.DataSource = Utility.PopulateImagesDdl();
        ddlGroupImage.DataBind();
        ddlGroupImage.Items.Insert(0, "Select Image");

        ddlGroupKernel.DataSource = Utility.GetKernels();
        ddlGroupKernel.DataBind();
        ListItem itemKernel = ddlGroupKernel.Items.FindByText("kernel");
        if (itemKernel != null)
            ddlGroupKernel.SelectedValue = "speed";
        else
            ddlGroupKernel.Items.Insert(0, "Select Kernel");

        ddlGroupBootImage.DataSource = Utility.GetBootImages();
        ddlGroupBootImage.DataBind();
        ListItem itemBootImage = ddlGroupBootImage.Items.FindByText("initrd.gz");
        if (itemBootImage != null)
            ddlGroupBootImage.SelectedValue = "initrd.gz";
        else
            ddlGroupBootImage.Items.Insert(0, "Select Boot Image");

        lbScripts.DataSource = Utility.GetScripts();
        lbScripts.DataBind();

        txtGroupName.Text = group.Name;
        txtGroupDesc.Text = group.Description;
        ddlGroupImage.Text = group.Image;
        ddlGroupKernel.Text = group.Kernel;
        ddlGroupBootImage.Text = group.BootImage;
        txtGroupArguments.Text = group.Args;
        txtGroupSenderArgs.Text = group.SenderArgs;
        if (!string.IsNullOrEmpty(group.Scripts))
        {
            List<string> listhostScripts = group.Scripts.Split(',').ToList<string>();
            foreach (ListItem item in lbScripts.Items)
                foreach (var script in listhostScripts)
                    if (item.Value == script)
                        item.Selected = true;
        }

        gvRemove.DataSource = group.CurrentMembers(group.Name);
        gvRemove.DataBind();

        Utility utility = new Utility();
        if (utility.GetSettings("Default Host View") == "all")
            PopulateGrid();
    }
Пример #18
0
    public DataTable TableForUser(string search)
    {
        Group group = new Group();
        WDSUser user = new WDSUser();
        user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
        user = user.Read(user);
        DataTable table = group.Search(search);

        if (!string.IsNullOrEmpty(user.GroupManagement))
        {
             List<string> listManagementGroups = user.GroupManagement.Split(' ').ToList<string>();

             List<string> groupNames = new List<string>();
             foreach (string id in listManagementGroups)
             {
                  group.ID = id;
                  group = group.Read(group);
                  groupNames.Add(group.Name);
             }
             foreach (DataRow row in table.Rows)
             {
                  if (!groupNames.Contains(row["groupname"].ToString()))
                       row.Delete();
             }
        }
        else
        {
             foreach (DataRow row in table.Rows)
             {
               row.Delete();
             }
        }

        return table;
    }
Пример #19
0
    protected void edit_page()
    {
        Master.Msgbox(Utility.Message);

        if (Master.IsInMembership("User"))
        {
            WDSUser user = new WDSUser();
            user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
            user    = user.Read(user);
            List <string> listManagementGroups = user.GroupManagement.Split(' ').ToList <string>();

            bool isAuthorized = false;
            foreach (string id in listManagementGroups)
            {
                if (group.ID == id)
                {
                    isAuthorized = true;
                    break;
                }
            }

            if (!isAuthorized)
            {
                Response.Redirect("~/views/dashboard/dash.aspx?access=denied");
            }
        }

        ddlGroupImage.DataSource = Utility.PopulateImagesDdl();
        ddlGroupImage.DataBind();
        ddlGroupImage.Items.Insert(0, "Select Image");

        ddlGroupKernel.DataSource = Utility.GetKernels();
        ddlGroupKernel.DataBind();
        ListItem itemKernel = ddlGroupKernel.Items.FindByText("kernel");

        if (itemKernel != null)
        {
            ddlGroupKernel.SelectedValue = "speed";
        }
        else
        {
            ddlGroupKernel.Items.Insert(0, "Select Kernel");
        }

        ddlGroupBootImage.DataSource = Utility.GetBootImages();
        ddlGroupBootImage.DataBind();
        ListItem itemBootImage = ddlGroupBootImage.Items.FindByText("initrd.gz");

        if (itemBootImage != null)
        {
            ddlGroupBootImage.SelectedValue = "initrd.gz";
        }
        else
        {
            ddlGroupBootImage.Items.Insert(0, "Select Boot Image");
        }


        lbScripts.DataSource = Utility.GetScripts();
        lbScripts.DataBind();

        txtGroupName.Text       = group.Name;
        txtGroupDesc.Text       = group.Description;
        ddlGroupImage.Text      = group.Image;
        ddlGroupKernel.Text     = group.Kernel;
        ddlGroupBootImage.Text  = group.BootImage;
        txtGroupArguments.Text  = group.Args;
        txtGroupSenderArgs.Text = group.SenderArgs;
        if (!string.IsNullOrEmpty(group.Scripts))
        {
            List <string> listhostScripts = group.Scripts.Split(',').ToList <string>();
            foreach (ListItem item in lbScripts.Items)
            {
                foreach (var script in listhostScripts)
                {
                    if (item.Value == script)
                    {
                        item.Selected = true;
                    }
                }
            }
        }

        gvRemove.DataSource = group.CurrentMembers(group.Name);
        gvRemove.DataBind();

        Utility utility = new Utility();

        if (utility.GetSettings("Default Host View") == "all")
        {
            PopulateGrid();
        }
    }