Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to open 'Select Users Or Groups' window using c#

Posted on 2009-04-18
5
Medium Priority
?
2,403 Views
Last Modified: 2013-12-17
I need a c# (VS2008) code to open the 'Select Users Or Groups' window, select users and/or groups of the connected computer or AD and copy them to any kind of list (string[]' listview, etc).

Thanks.
SelectUsersOrGroups.jpg
0
Comment
Question by:OrenRozen
  • 3
  • 2
5 Comments
 
LVL 3

Author Comment

by:OrenRozen
ID: 24175777
I've already found both links and downloaded the sources from codeproject, but I'm unable to figure out how to use it.

I've copy the code from the codeproject page, added a reference to the helper dll but having problem with
'ADFlagConstants'.

Can you please help in completing the code to open the dialog box?

Thanks.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace MySelectUsersAndGroups
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            // grab the helper object
 
            ObjectPickerHelper.CADObjectPicker picker =
               new ObjectPickerHelper.CADObjectPickerClass();
            // mess with the flags
 
            picker.ScopeFlags =
             (uint)(ADFlagConstants.DSOP_SCOPE_FLAG.WANT_PROVIDER_WINNT);
            picker.ScopeTypeFlags =
             (uint)(ADFlagConstants.DSOP_SCOPE_TYPE.DOWNLEVEL_JOINED_DOMAIN |
                  ADFlagConstants.DSOP_SCOPE_TYPE.ENTERPRISE_DOMAIN |
                  ADFlagConstants.DSOP_SCOPE_TYPE.EXTERNAL_DOWNLEVEL_DOMAIN |
                  ADFlagConstants.DSOP_SCOPE_TYPE.EXTERNAL_UPLEVEL_DOMAIN |
                  ADFlagConstants.DSOP_SCOPE_TYPE.UPLEVEL_JOINED_DOMAIN |
                  ADFlagConstants.DSOP_SCOPE_TYPE.USER_ENTERED_DOWNLEVEL_SCOPE |
                  ADFlagConstants.DSOP_SCOPE_TYPE.USER_ENTERED_UPLEVEL_SCOPE |
                  ADFlagConstants.DSOP_SCOPE_TYPE.GLOBAL_CATALOG);
            picker.UplevelFilterFlags_Both =
             (uint)ADFlagConstants.DSOP_FILTER.COMPUTERS;
            picker.UplevelFilterFlags_Mixed = 0;
            picker.UplevelFilterFlags_Native = 0;
            picker.DownLevelFilterFlags =
             ADFlagConstants.DSOP_DOWNLEVEL_FILTER_COMPUTERS;
            picker.InitInfo_OptionFlags = (uint)ADFlagConstants.DSOP_FLAG.MULTISELECT;
 
 
            // show the dialog
 
            picker.InvokeDialog(UsersOrGroupsFrm.ActiveForm.Handle.ToInt32());
 
            // somehow C# seems more picky with the types than VB, 
 
            // so you have to use an intermediate var.
 
            ObjectPickerHelper.CADObjectColl coll =
             (ObjectPickerHelper.CADObjectColl)picker.ADObjectsColl;
 
            // and walk the collection
 
            int i = 0;
 
            foreach (ObjectPickerHelper.CADObjectInfo InfoObject in coll)
            {
                ListViewItem theItem = new ListViewItem(InfoObject.Name, i);
                theItem.SubItems.Add(InfoObject.Class);
                theItem.SubItems.Add(InfoObject.ADPath);
                theItem.SubItems.Add(InfoObject.UPN);
                listViewResults.Items.Add(theItem);
                i++;
            }
 
        }
    }
}

Open in new window

0
 
LVL 3

Accepted Solution

by:
OrenRozen earned 0 total points
ID: 24385038
solution was not provided
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 24391674
did you read the section Using the code in the code project site?
0
 
LVL 3

Author Comment

by:OrenRozen
ID: 24392979
yes I did.

As I said, I've copy the code from the codeproject page, added a reference to the helper dll but having problem with
'ADFlagConstants'.

You can see it in the attached code in my previous replay.

Thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question