コード例 #1
0
ファイル: Window1.xaml.cs プロジェクト: chenmj201601/UMP
        private void InitADUserData()
        {
            IListADUsers.Clear();
            IStrADPath = string.Format("LDAP://{0}", IStrADDomain);
            ADUtility util = new ADUtility(IStrADPath, IStrADUser, IStrADPassword);

            try
            {
                BindItem groupItem = listboxGroups.SelectedItem as BindItem;
                if (groupItem == null)
                {
                    return;
                }
                ADGroup groupUser = groupItem.Obj as ADGroup;
                if (groupUser == null)
                {
                    return;
                }

                string[] users = util.GetUsersForGroup(groupUser.Name);
                foreach (string user in users)
                {
                    BindItem item = new BindItem();
                    item.Name = user;
                    IListADUsers.Add(item);
                }
            }
            catch (Exception ex)
            {
                SubDebug(string.Format("Get all AD users fail.\t{0}", ex.Message));
            }
        }
コード例 #2
0
ファイル: Window1.xaml.cs プロジェクト: chenmj201601/UMP
        private void btnGetUser_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckInput())
            {
                SubDebug(string.Format("Input invalid."));
                return;
            }

            IListADUsers.Clear();
            IStrADPath = string.Format("LDAP://{0}", IStrADDomain);
            ADUtility util = new ADUtility(IStrADPath, IStrADUser, IStrADPassword);

            try
            {
                ADUserCollection users = util.GetAllUsers();
                foreach (ADUser user in users)
                {
                    BindItem item = new BindItem();
                    item.Name    = user.AccountName;
                    item.Display = user.DisplayName;
                    item.Obj     = item;
                    IListADUsers.Add(item);
                }
            }
            catch (Exception ex)
            {
                SubDebug(string.Format("Get all AD users fail.\t{0}", ex.Message));
            }
        }
コード例 #3
0
ファイル: Window1.xaml.cs プロジェクト: chenmj201601/UMP
        private void InitADGroupData()
        {
            IListADGroups.Clear();
            IStrADPath = string.Format("LDAP://{0}", IStrADDomain);
            ADUtility util = new ADUtility(IStrADPath, IStrADUser, IStrADPassword);

            try
            {
                ADGroupCollection groups = util.GetAllGroups();
                foreach (ADGroup group in groups.AllItem)
                {
                    BindItem item = new BindItem();
                    item.Name    = group.Name;
                    item.Display = group.DisplayName;
                    item.Obj     = group;
                    IListADGroups.Add(item);
                }
            }
            catch (Exception ex)
            {
                SubDebug(string.Format("Get all AD groups fail.\t{0}", ex.Message));
            }
        }