0

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?

Murat Korkmaz
  • 1,329
  • 2
  • 19
  • 37

3 Answers3

1

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

ziyasal
  • 549
  • 5
  • 15
  • Thanks for the response. I saw your project, but a little confused whether it's possible to use it in commercial applications. On the main page it refers to the GPL license, while in the logs I see a note that it was converted to LGPL. – Murat Korkmaz Dec 02 '14 at 14:59
  • To clarify, project doesn't mine. There is another one http://adui.codeplex.com/ if you want. Its licence is Ms-PL. – ziyasal Dec 02 '14 at 15:09
  • Thanks for the suggestions! Which one is better and more stable by your opinion? – Murat Korkmaz Dec 02 '14 at 15:18
  • You're welcome, You should check which one meet your needs. I think adui.codeplex.com looks stable. – ziyasal Dec 02 '14 at 16:53
1

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

Ricardo Polo Jaramillo
  • 12,110
  • 13
  • 58
  • 83
-1

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);
        }
    }
}
Walter Verhoeven
  • 3,867
  • 27
  • 36