The following C# code example assigns a task to a user
named tony blue.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO ;
namespace ForwardTask
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
TaskManagerServiceService taskManager = new TaskManagerServiceService();
taskManager.Credentials = new System.Net.NetworkCredential("administrator", "password");
//Get the identifier of the user to whom the task is sent
//Create a DirectoryManagerServiceService object
DirectoryManagerServiceService svc = new DirectoryManagerServiceService();
// Provide authentication credentials to the service
svc.Credentials = new System.Net.NetworkCredential(
"administrator",
"password"
);
//Find a local user
PrincipalSearchFilter psf = new PrincipalSearchFilter();
psf.userId= "tblue";
object[] principalList = svc.findPrincipalsWithFilter(psf);
string localUserId = "";
User testUser = null;
if (principalList.Length > 0)
{
testUser = (User)(principalList[0]);
localUserId = testUser.oid;
}
//Forward the task to the user
taskManager.forwardTask(204,true,localUserId);
}
catch (Exception ee)
{
Console.WriteLine("An unexpected exception was encountered: " + ee.Message + "\n" + ee.StackTrace);
}
}
}
}
|
|
|