-
Notifications
You must be signed in to change notification settings - Fork 9
Getting started
Ryan Newington edited this page May 27, 2016
·
1 revision
The Lithnet Resource Management Client is designed to be easy to use and get started
- Create a new project in Visual Studio
- Ensure Microsoft.ResourceManagement.dll is registered in the GAC (you can find this on your FIM service server)
- Install the nuget package from the Package Manager Console in Visual Studio
- Update the app.config or web.config file to point to your FIM service server
<lithnetResourceManagementClient resourceManagementServiceBaseAddress="http://fimsvc-sspr:5725" />Now you can start coding. This simple app demonstrates the basic get, search, update, and create operations.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lithnet.ResourceManagement.Client;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// Create an instance of the resource management client
ResourceManagementClient client = new ResourceManagementClient();
// Get the resource with the account name 'testuser'
ResourceObject resource = client.GetResourceByKey("Person", "AccountName", "testuser");
// Write the object to the console
Console.WriteLine(resource.ToString());
// Get a single attribute
Console.WriteLine(resource.Attributes["AccountName"].StringValue);
// Change an attribute
resource.Attributes["AccountName"].SetValue("NewUsername");
// Save the resource to the fim service
resource.Save();
// Create a new object
ResourceObject newResource = client.CreateResource("Person");
newResource.Attributes["AccountName"].SetValue("MyNewAccount");
newResource.Attributes["Domain"].SetValue("FIM-DEV1");
// Save the new object to the fim service
newResource.Save();
// Search for the newly created object by anchor
ResourceObject foundObject = client.GetResourceByKey("Person", "AccountName", "MyNewAccount");
// Delete the object
client.DeleteResource(foundObject);
// Print the values of the object
Console.WriteLine(foundObject.ToString());
// Search for all Sets
foreach (ResourceObject result in client.GetResources("/Set"))
{
Console.WriteLine(result.ToString());
}
}
}
}