The following C# code example deletes a user named Wendy
Blue from LiveCycle. (See Deleting 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 DeleteUser.ServiceReference1;
namespace DeleteUser
{
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 PrincipalSearchFilter to find the user to delete
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 and delete the user
for (int i = 0; i < index; i++)
{
User theUser = (User)allUsers[i];
dirManClient.deleteLocalUser(theUser.oid);
}
}
catch (Exception ee)
{
Console.WriteLine(ee.Message);
}
}
}
}
|
|
|