Skip to content

Getting started

Ryan Newington edited this page Jul 16, 2026 · 2 revisions

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.

Install the package

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.

Create a client

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.

Basic operations

// 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).

Searching

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);
}

Upgrading from version 1

Version 2 is a substantial modernization, and two setup steps from version 1 no longer exist:

  • Microsoft.ResourceManagement.dll is 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 via IOptions<T>), rather than through an app.config section.

Next steps

Clone this wiki locally