-
Notifications
You must be signed in to change notification settings - Fork 9
Getting started
The Lithnet Resource Management Client is a .NET library for working with the FIM/MIM service. It gives you a strongly typed API over the service's web service endpoints, with none of the WCF binding configuration to manage. Version 2 runs on .NET Framework and modern .NET, on Windows, Linux, and macOS.
Add the Lithnet.ResourceManagement.Client NuGet package to your project:
dotnet add package Lithnet.ResourceManagement.Client
That is all the setup there is. The library does not use Microsoft.ResourceManagement.dll -- nothing needs to be copied from the MIM server or registered in the GAC.
Connection settings are provided in code through ResourceManagementClientOptions. With no options, the client connects to the MIM service on the local machine as the current user.
using Lithnet.ResourceManagement.Client;
var client = new ResourceManagementClient(new ResourceManagementClientOptions
{
BaseUri = "http://mim-service:5725"
});To connect with credentials other than the current user's, set Username and Password on the options. In applications that use dependency injection, the constructor also accepts IOptions<ResourceManagementClientOptions>, so the options can be bound from your configuration system and the client registered in the container.
The library works out how to reach the service automatically, based on your platform and runtime. See the connection guide for the connection modes, platform support, and the full options reference.
// Get a resource by a key attribute
IResourceObject resource = client.GetResourceByKey("Person", "AccountName", "testuser");
// Read attribute values
Console.WriteLine(resource.DisplayName);
Console.WriteLine(resource.Attributes["AccountName"].StringValue);
// Modify and save
resource.Attributes["JobTitle"].SetValue("Identity architect");
resource.Save();
// Create a new resource
IResourceObject newResource = client.CreateResource("Person");
newResource.Attributes["AccountName"].SetValue("jsmith");
newResource.Attributes["Domain"].SetValue("CORP");
newResource.Save();
// Delete a resource
client.DeleteResource(newResource);Every operation has an async counterpart (GetResourceByKeyAsync, SaveAsync, DeleteResourceAsync, and so on).
Searches use the same XPath dialect as the MIM portal and service. Results are enumerated lazily, and you can restrict the attributes returned to keep large queries fast.
foreach (IResourceObject result in client.GetResources("/Set", new[] { "DisplayName" }))
{
Console.WriteLine(result.DisplayName);
}Version 2 is a substantial modernization, and two setup steps from version 1 no longer exist:
-
Microsoft.ResourceManagement.dllis not used, so there is nothing to obtain from the MIM server or register in the GAC. - Connection settings are supplied in code through
ResourceManagementClientOptions(or bound viaIOptions<T>), rather than through an app.config section.
- The connection guide covers connection modes, cross-platform support, authentication, and troubleshooting.
- The proxy installation guide covers the proxy MSI used for remote proxy connections and application-control-locked environments.
- The API documentation has the full reference.
- Prefer PowerShell? The LithnetRMA module is built on this library.