Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         using (var loader = new Common.Loader<string>(o =>
                                             {
                                                 System.Threading.Thread.Sleep(10000); 
                                             }))
         {
             loader.RunWorker();
         };  
     }
     catch (Exception)
     {
         throw;
     }
 }
        private void RefreshListing()
        {
            try
            { 
                using (var loader = new Common.Loader<string>(o =>
                { 
                    if (_ModuleReferece == BTSS.Common.Core.ModuleReference.Tools)
                        data = activeDirectoryGroup.GetActiveDirectoryGroupList(_Domain);
                    else if (_ModuleReferece == BTSS.Common.Core.ModuleReference.Setting)
                        data = activeDirectoryGroup.GetActiveDirectoryGroupList(""); //select ALL group if module reference is Settings.
                }))
                {
                    loader.RunWorker();
                };
                 
                userControlListingGroup.DataSource = data;

            }
            catch (Exception)
            {
                throw;
            }
        }
Example #3
0
        private void RefreshListing()
        {
            try
            {
                id = "";
                userControlButtonsMain.ButtonsMode = BTSS.Common.UserControls.UserControlButtonsMain.Mode.Default;

                using (var loader = new Common.Loader<string>(o =>
                { 
                    data = group.GetGroupList();
                }))
                {
                    loader.RunWorker();
                };
                 
                userControlListing.DataSource = data; 
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #4
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            try
            { 
                if (textBoxSearch.TextLength > 0)
                {
                    string textSearch = textBoxSearch.Text;
                    List<Users> users = new List<Users>();
                    
                    DataTable groups = new DataTable();
                    groups.Columns.Add("domain");
                    groups.Columns.Add("group");
                    groups.Rows.Add("PRD", "business technologies db users");
                    groups.Rows.Add("PRD", "SHR MNE1050 Dept Ops Business Tech - RWM"); 
                    groups.Rows.Add("MLIDDOMAIN1", "business technology db users");

                    using (var loader = new Common.Loader<string>(o =>
                    { 
                        //Start of: getting the data.
                        for (int i = 0; i <= groups.Rows.Count - 1; i++)
                        {
                            using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, groups.Rows[i]["domain"].ToString()))
                            {
                                GroupPrincipal gp = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, groups.Rows[i]["group"].ToString());
                                
                                var usr = (from a in gp.Members
                                           where a.DisplayName.ToLower().Contains(textSearch.ToLower())
                                           select new Users()
                                           {
                                               UserName = a.SamAccountName,
                                               AccountName = a.SamAccountName,
                                               DisplayName = a.DisplayName,
                                               Email = ((UserPrincipal)a).EmailAddress,
                                               LastName = ((UserPrincipal)a).Surname,
                                               FirstName = ((UserPrincipal)a).GivenName,
                                               MiddleName= ((UserPrincipal)a).MiddleName,
                                               Domain = groups.Rows[i]["domain"].ToString()
                                           });

                                users.AddRange(usr); 
                            }
                        }
                        //End of: getting the data.
                    }))
                    {
                        loader.RunWorker();
                    };

                    dataGridViewUsers.DataSource = users.OrderBy(a => a.DisplayName).ToList(); 
                        
                } 

            }
            catch (Exception)
            {
                throw;
            }
        }
Example #5
0
        private void RefreshListing()
        {
            try
            {
                string tableName = "";
                string userName = "";

                if (treeViewAudit.SelectedNode.Parent != null)
                {  
                    if (treeViewAudit.SelectedNode.Parent.Text == "Tables")
                        tableName = treeViewAudit.SelectedNode.Text;
                    if (treeViewAudit.SelectedNode.Parent.Text == "Users")
                        userName = treeViewAudit.SelectedNode.Text;

                    using (var loader = new Common.Loader<string>(o =>
                    {
                        if (tableName.Length > 0)
                            data = audit.GetAuditListByTable(tableName);
                        if (userName.Length > 0)
                            data = audit.GetAuditListByUser(userName);
                    }))
                    {
                        loader.RunWorker();
                    }; 

                    userControlListing.DataSource = data; 
                } 
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void LoadData()
        {
            try
            {

                PrincipalContext context = new PrincipalContext(ContextType.Domain, _Domain);
                                
                switch (_TransactionType)
                { 
                    case TransactionTypes.MemberOfGroup: 
                        
                        using (var loader = new Common.Loader<string>(o =>
                        {
                            GroupPrincipal gp = GroupPrincipal.FindByIdentity(context, IdentityType.Name, _Name);

                            users = (from u in gp.Members
                                     select new Logic.DomainUser { DisplayName = u.DisplayName == null ? "":u.DisplayName, UserName = u.SamAccountName, Domain = u.Context.Name }).OrderBy(a => a.DisplayName).ToList();
                        }))
                        {
                            loader.RunWorker();
                        };
  
                        userControlListingData.DataSource = users; 
                        break;
                    case TransactionTypes.GroupsOfUser: 

                        UserPrincipal up = UserPrincipal.FindByIdentity(context, _Name);

                        if (up == null) break;  

                       
                        using (var loader = new Common.Loader<string>(o =>
                        {
                            PrincipalSearchResult<Principal> principalSearchResult = up.GetGroups();

                            groups = (from u in principalSearchResult.ToList()
                                      select new Logic.DomainGroup { Name = u.Name, Domain = u.Context.Name }).OrderBy(a => a.Name);                        
                        }))
                        {
                            loader.RunWorker();
                        };

                        userControlListingData.DataSource = groups;
                        break;                         
                    case TransactionTypes.SearchGroupOrUser:  
                        if (_SearchType == SearchTypes.User)
                        {
                         
                            using (var loader = new Common.Loader<string>(o =>
                            {
                                UserPrincipal userPrincipal = new UserPrincipal(context);
                                StringBuilder sbUser = new StringBuilder();
                                sbUser.Append("*").Append(_Name).Append("*");
                                userPrincipal.DisplayName = sbUser.ToString(); 

                                PrincipalSearcher psUser = new PrincipalSearcher(userPrincipal);
                                  
                                users = (from u in psUser.FindAll().ToList()
                                         select new Logic.DomainUser { DisplayName = u.DisplayName == null ? "" : u.DisplayName, UserName = u.SamAccountName, Domain = u.Context.Name }).OrderBy(a => a.DisplayName).ToList();
                                  
                            }))
                            {
                                loader.RunWorker();  
                            };
                            userControlListingData.DataSource = users;

                        }
                        else //Group
                        { 
                            using (var loader = new Common.Loader<string>(o =>
                            {
                                GroupPrincipal groupPrincipal = new GroupPrincipal(context);
                                StringBuilder sbGroup = new StringBuilder();
                                sbGroup.Append("*").Append(_Name).Append("*");
                                groupPrincipal.Name = sbGroup.ToString();

                                PrincipalSearcher psGroup = new PrincipalSearcher(groupPrincipal);


                                groups = (from u in psGroup.FindAll().ToList()
                                      select new Logic.DomainGroup { Name = u.Name, Domain = u.Context.Name }).OrderBy(a => a.Name);
                            }))
                            {
                                loader.RunWorker();                            
                            };
                            
                            userControlListingData.DataSource = groups; 
                        } 
                        break;
                }
                  
            }
            catch (Exception)
            {

                throw;
            }
        }
        private void LoadSearch()
        {
            try
            {
                data = new List<BTSS.Logic.DomainGroup>();

                using (var loader = new Common.Loader<string>(o =>
                {
                    foreach (string domain in _Domain.Split(','))
                    {
                        PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domain);
                        GroupPrincipal gp = new GroupPrincipal(ctx);

                        StringBuilder sb = new StringBuilder();
                        sb.Append("*").Append(_TextSearch).Append("*");

                        gp.Name = sb.ToString();

                        PrincipalSearcher ps = new PrincipalSearcher(gp);

                        var list = (from u in ps.FindAll()
                                select new Logic.DomainGroup { Name = u.Name, Domain = u.Context.Name }).OrderBy(a => a.Name);
                        
                        data.AddRange(list.ToList()); 
                    } 
                }))
                {
                    loader.RunWorker();
                };
                                  
                userControlListingData.DataSource = data; 
            }
            catch (Exception)
            {
                throw;
            }
        }