Reputation: 1347
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?
Upvotes: 0
Views: 1184
Reputation: 4411
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);
}
}
}
Upvotes: -1
Reputation: 12318
I created a nuget very easy to use in C# https://github.com/Tulpep/Active-Directory-Object-Picker
Upvotes: 1
Reputation: 558
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
Upvotes: 1