示例#1
0
        private void FillUsersWithSameGroup(ref PanelItemBase parent, ref ICollection <PanelItemBase> result, string startPath, string group)
        {
            using (var searcher = new DirectorySearcher())
            {
                searcher.SearchRoot = new DirectoryEntry(startPath);
                searcher.PageSize   = Int32.MaxValue;
                searcher.Filter     = "(objectCategory=person)";
                SetupPropertiesToLoad(searcher);
                searcher.PropertiesToLoad.Add(Constants.MEMBER_OF);
                try
                {
                    var results = searcher.FindAll();
                    foreach (SearchResult row in results)
                    {
                        // skip disabled users
                        var userAccControl = int.Parse(LdapUtils.SearchResult_GetString(row, Constants.ACCOUNT_CONTROL));
                        if ((userAccControl & 2) != 0)
                        {
                            continue;
                        }

                        var list = row.Properties[Constants.MEMBER_OF];
                        if (list.Contains(group))
                        {
                            result.Add(BuildUserFromSearchResult(parent, row));
                        }
                    }
                    results.Dispose();
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                }
            }
        }
示例#2
0
        //public override int CountColumns
        //{
        //    get { return base.CountColumns; }
        //}

        public override IComparable GetValue(int index)
        {
            switch (index)
            {
            //case 1: return AdsPath;
            default:
                return(LdapUtils.UnescapeName(Name));
            }
        }
示例#3
0
        public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
        {
            var startPath = LdapUtils.GetDCNameFromPath(LdapUtils.GetUserPath(PluginUsers.ScreenService.UserName), 2);
            var workspace = parent as WorkspacePanelItem;

            if (workspace != null)
            {
                FillUsersWithSameGroup(ref parent, ref result, startPath, workspace.AdsPath);
            }
            else
            {
                FillUsers(ref parent, ref result, startPath);
            }
        }
示例#4
0
        private UserPanelItem BuildUserFromSearchResult(PanelItemBase parent, SearchResult row)
        {
            var user = new UserPanelItem(parent, LdapUtils.SearchResult_GetString(row, Constants.CN));

            user.AdsPath        = LdapUtils.SearchResult_GetString(row, Constants.ADSPATH);
            user.Title          = LdapUtils.SearchResult_GetString(row, Constants.TITLE);
            user.WorkPhone      = LdapUtils.SearchResult_GetString(row, Constants.WORK_PHONE);
            user.Office         = LdapUtils.SearchResult_GetString(row, Constants.OFFICE);
            user.Department     = LdapUtils.SearchResult_GetString(row, Constants.DEPARTMENT);
            user.Email          = LdapUtils.SearchResult_GetString(row, Constants.EMAIL);
            user.Company        = LdapUtils.SearchResult_GetString(row, Constants.COMPANY);
            user.Nickname       = LdapUtils.SearchResult_GetString(row, Constants.NICKNAME);
            user.LegacyLogon    = LdapUtils.SearchResult_GetString(row, Constants.LEGACY_LOGON);
            user.Description    = LdapUtils.SearchResult_GetString(row, Constants.DESCRIPTION);
            user.UserAccControl = int.Parse(LdapUtils.SearchResult_GetString(row, Constants.ACCOUNT_CONTROL));
            user.EmployeeID     = LdapUtils.SearchResult_GetString(row, Constants.EMPLOYEE_ID);
            //user.WorkPhone = "0x" + user.UserAccControl.ToString("X");
            //user.Description = row["lockoutTime"].ToString();
            return(user);
        }
示例#5
0
        public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
        {
            string startPath;

            if (parent is UserPanelItem)
            {
                startPath = (parent as UserPanelItem).AdsPath;
            }
            else
            {
                startPath = LdapUtils.GetUserPath(PluginUsers.ScreenService.UserName);
            }

            using (var searcher = new DirectorySearcher())
            {
                // execute filter query to Active Directory
                searcher.SearchRoot = new DirectoryEntry(startPath);
                searcher.PageSize   = Int32.MaxValue;
                searcher.Filter     = "(objectCategory=person)"; // lockoutTime
                searcher.PropertiesToLoad.Add(Constants.MEMBER_OF);
                try
                {
                    var row = searcher.FindOne();

                    var list = row.Properties[Constants.MEMBER_OF];
                    foreach (var value in list)
                    {
                        var valueStr = (string)value;

                        var workspace = new WorkspacePanelItem(parent, LdapUtils.GetLdapValue(valueStr));
                        workspace.AdsPath = valueStr;
                        result.Add(workspace);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                }
            }
        }
示例#6
0
        private void FillUsers(ref PanelItemBase parent, ref ICollection <PanelItemBase> result, string startPath)
        {
            using (var searcher = new DirectorySearcher())
            {
                // execute filter query to Active Directory
                searcher.SearchRoot = new DirectoryEntry(startPath);
                searcher.PageSize   = Int32.MaxValue;
                searcher.Filter     = "(objectCategory=person)"; // lockoutTime
                //var filter = "(&(&(|(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(groupType:1.2.840.113556.1.4.804:=14)))objectCategory=user)(cn=khmau.isup_builder)))";
                //var filter = "(&(&(&(objectCategory=person)(objectClass=user)(lockoutTime:1.2.840.113556.1.4.804:=4294967295))))";
                //var filter = "(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=16))";
                //var filter = "((!userAccountControl:1.2.840.113556.1.4.803:=2))";
                //var filter = "(!(userAccountControl:1.2.840.113556.1.4.803:=2))";
                SetupPropertiesToLoad(searcher);
                try
                {
                    var results = searcher.FindAll();
                    foreach (SearchResult row in results)
                    {
                        // skip disabled users
                        var userAccControl = int.Parse(LdapUtils.SearchResult_GetString(row, Constants.ACCOUNT_CONTROL));
                        if ((userAccControl & 2) != 0)
                        {
                            continue;
                        }

                        result.Add(BuildUserFromSearchResult(parent, row));
                    }
                    results.Dispose();
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                }
            }
        }
示例#7
0
 public UserRoot()
 {
     m_StartPath = LdapUtils.GetUserPath(PluginUsers.ScreenService.UserName);
     m_StartPath = LdapUtils.GetDCNameFromPath(m_StartPath, 2);
 }
示例#8
0
 protected override string GetName()
 {
     return(LdapUtils.GetLdapValue(m_StartPath));
 }