The following C# code example adds a user named Wendy Blue
to LiveCycle. (See Adding Users.)
???/**
* Ensure that you create a .NET project that uses
* MS Visual Studio 2008 and version 3.5 of the .NET
* framework. This is required to invoke a
* LiveCycle service using MTOM.
*
* For information, see "Invoking LiveCycle using MTOM" in Programming with LiveCycle
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.IO;
//A reference to the DirectoryManager service
using AddUser.ServiceReference1;
namespace AddUser
{
class Program
{
static void Main(string[] args)
{
try
{
//Create a DirectoryManagerServiceClient object
DirectoryManagerServiceClient dirManClient = new DirectoryManagerServiceClient();
dirManClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/DirectoryManagerService?blob=mtom");
//Enable BASIC HTTP authentication
BasicHttpBinding b = (BasicHttpBinding)dirManClient.Endpoint.Binding;
b.MessageEncoding = WSMessageEncoding.Mtom;
dirManClient.ClientCredentials.UserName.UserName = "administrator";
dirManClient.ClientCredentials.UserName.Password = "password";
b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
b.MaxReceivedMessageSize = 2000000;
b.MaxBufferSize = 2000000;
b.ReaderQuotas.MaxArrayLength = 2000000;
//Create a User object
UserImpl myUser = new UserImpl();
myUser.domainName = "DefaultDom";
myUser.userid = "wblue";
myUser.canonicalName = "wblue";
myUser.principalType = "USER";
myUser.givenName = "Wendy";
myUser.familyName = "Blue";
myUser.disabled = false;
//Add the user to LiveCycle
dirManClient.createLocalUser(myUser, "password");
//Ensure that the user was added
//Create a PrincipalSearchFilter to find the user by ID
PrincipalSearchFilter psf = new PrincipalSearchFilter();
psf.userId = "wblue";
MyArrayOfUser allUsers = dirManClient.findUsers(psf);
//Determine how many elements there are
//Each element is of type User
int index = allUsers.Count;
//Iterate through the array
for (int i = 0; i < index; i++)
{
User theUser =(User) allUsers[i];
Console.WriteLine("User ID: " + theUser.userid);
Console.WriteLine("User name: " + theUser.givenName + " " + theUser.familyName);
Console.WriteLine("User Domain: " + theUser.domainName);
}
}
catch (Exception ee)
{
Console.WriteLine(ee.Message);
}
}
}
}
|
|
|