Please suggest a Windows Object Picker C# wrapper

1.1k views Asked by At

I need to programmatically assign Windows and Active Directory users to the Window Authorization Manager (AzMan) roles via the Windows Object Picker. So I can invoke the "User and Group Permissions" window from my C# program.

Can anybody suggest a C# wrapper for the Windows Object Picker?

3

There are 3 answers

4
ziyasal On BEST ANSWER

Here is custom dialog class DirectoryObjectDialog that wraps the COM directory object picker.

Sample usage;

var dlg = new DirectoryObjectDialog
{
    MultiSelect = true
};
dlg.AddScope(DirectoryScope.Computer, users: true, groups: true);
dlg.AddScope(DirectoryScope.Domain, users: true, groups: true);
if (dlg.ShowDialog() == DialogResult.OK)
{
    foreach (var sel in dlg.Selections)
        Console.WriteLine("{0}: {1}", sel.Principal.SamAccountName, sel.Principal.Sid);
}

For detailed information available here

0
Walter Verhoeven On

I like nuget package Tulpep.ActiveDirectoryObjectPicker

Here is a sample https://github.com/Tulpep/Active-Directory-Object-Picker

DirectoryObjectPickerDialog picker = new DirectoryObjectPickerDialog()
{
    AllowedObjectTypes = ObjectTypes.Users | ObjectTypes.Groups | ObjectTypes.Computers,
    DefaultObjectTypes = ObjectTypes.Computers,
    AllowedLocations = Locations.All,
    DefaultLocations = Locations.JoinedDomain,
    MultiSelect = true,
    ShowAdvancedView = true
};
using (picker)
{
    if (picker.ShowDialog() == DialogResult.OK)
    {
        foreach (var sel in picker.SelectedObjects)
        {
            Console.WriteLine(sel.Name);
        }
    }
}
0
Ricardo Polo Jaramillo On

I created a nuget very easy to use in C# https://github.com/Tulpep/Active-Directory-Object-Picker