Steps to reproduce the sample.
1. Install SPML provider (included with the Active Roles Installation media under \Solutions\SPML Provider) to a computer with IIS installed.
2. Ensure it works. Open url "http://<computer_host>/ARServerSPML/SPMLProvider.asmx". It looks like
3. Create a C# console project.
4. "Add Service Reference...", put url from point 2, and rename the reference to "ArsSPML".
5. Open a file "Program.cs" and put this code.
6. Run the project.
DESCRIPTION
This C# sample code demonstrates how to create a user account by Active Roles SPML provider.
Note This code may use interfaces from Active Roles ADSI Provider Type Library (EDMLib). Please, add a reference to the Active Roles ADSI Provider Type Library (EDMLib) to your C# project.
CODE
//********************************************************************************
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//
// IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
// PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.
//*********************************************************************************
using System;
using System.Collections.Generic;
using SampleAppl.ArsSPML;
namespace SampleAppl
{
class Program
{
static void Main(string[] args)
{
//-- Create request object
CAddRequest addRequest = new CAddRequest();
CPSOID containerForUser = new CPSOID();
containerForUser.ID = "OU=Baggins,DC=shire,DC=middle-earth,DC=com";
addRequest.containerID = containerForUser;
addRequest.returnData = "everything";
addRequest.targetID = "";
CPSOID ID = new CPSOID();
ID.ID = "";
addRequest.psoID = ID;
List<attr> attributes = new List<attr>();
attributes.Add(CreateAttribute("cn", new object[] { "Frodo Baggins" }));
attributes.Add(CreateAttribute("description", new object[] { "He has a quest." }));
attributes.Add(CreateAttribute("sAMAccountName", new object[] { "fbaggins" }));
attributes.Add(CreateAttribute("objectClass", new object[] { "user" }));
attributes.Add(CreateAttribute("edsaPassword", new object[] { "SauronMustDie!" }));
addRequest.data = attributes.ToArray();
//-- Create web service instance
ActiveRolesSPMLProviderSoapClient webService = new ActiveRolesSPMLProviderSoapClient();
//-- Send request and get response
CAddResponse myresponse = webService.add(addRequest);
//-- Show error info
if (!String.IsNullOrEmpty(myresponse.errorMessage))
Console.WriteLine(myresponse.errorMessage);
}
static attr CreateAttribute(string name, object[] values)
{
attr attribute = new attr();
attribute.name = name;
attribute.value = values;
return attribute;
}
}
}
//***** END OF CODE ***************************************************************