using System;
using System.Collections.Generic;
using System.Text;
using com.opentext.api;
/*For more samples on java you could always visit
[URL unfurl="true"]http://www.greggriffiths.org/livelink/development/lapi/[/URL]
I started with java so C# was a pretty easy switch
Just follow the rudimentaries on your proj refrences
which are using com.opentext.api which should eb installed on the
client.LAPI_Netp and LAPI_SSPIp if you are doing dir svcs stuff
rather than socket calls.vjslib so that you can get native java stuff
I also work and program in oscript so debugging lapi is kind of easy for me
but basically lapi gives everything out to you as huge beautiful data structures
so rev up your Sartaj Sahni and Ellis Horowitz books Data Structures(the things
you learned in CS but never thought would use)
*/
/*
Intent of the program
Access a livelink personal workspace using Livelink API and DirSvcs running on the
livelink server
Tested with hideen password option on an IIS machine that has
Basic Authentication checked.Creds from AD
If succesfull I put something in the personal workspace
THIS CODE MAY NOT BE USED FOR PRODUCTION UNLESS YOU KNOW WHAT IT DOES
THIS IS EXPLANATORY CODE AND I AS AUTHOR CANNOT B HELD LIABLE FOR
ANY DAMAGE TO YOUR SYSTEM
*/
namespace ConnectAsZID
{
class Program
{
static void Main(string[] args)
{
/*Make a LAPI tunneled call*/
/*Do not know how HTTPS works*/
try
{
LLSession session = null;
LAPI_DOCUMENTS documents = null;
int status = 0;
int nodeID = 0;
int parentID = 0;
int nodeVol = 0;
int parentVol = 0;
LLValue pwsInfo = (new LLValue()).setAssocNotSet();
LLValue objInfo = (new LLValue()).setAssocNotSet();
LLValue versionInfo = (new LLValue()).setAssocNotSet();
// Instantiate session object as a SOCKET call
//session = new LLSession("houlnkdev1", 2099, "",
// "zknn1", "password", null);
// Instantiate session object as a TUNNELED call
//Here LAPI is making use of the logged in user
//For HTTP Connection***********************************
String Server = "255.255.255.1"; //the livelink server IP or a DNS name for the web server
int Port = 80; //We are hitting the web server
String DFT = "";
String User = "domain\\zknn1";//submit domain or you could get it from windows
String Pass = "password"; //the correct password not needed dummy will suffice
LLValue config = new LLValue().setAssoc();
config.add("HTTPS", 0);
config.add("LivelinkCGI", "/HOULivelinkTest/llisapi.dll");
config.add("EnableNTLM", 1);
config.add("HTTPUserName", "");//Putting my ad username here did not work
config.add("HTTPPassword", "");//Same as above
session = new LLSession(Server, Port, DFT, User, Pass, config);
// Instantiate documents object
documents = new LAPI_DOCUMENTS(session);
// Access the user's Personal Workspace
status = documents.AccessPersonalWS(pwsInfo);
if (status == 0)
{
Console.WriteLine("Accessed Personal Workspace");
parentVol = pwsInfo.toInteger("VolumeID");
parentID = pwsInfo.toInteger("ID");
Console.WriteLine("ParentVol****" + parentVol);
Console.WriteLine("ParentID****" + parentID);
}
if (status == 0)
{
// Add document
status = documents.AddDocument(parentVol, parentID,
"Nair's Document", "c:\\temp\\helloworld.txt",
objInfo, versionInfo);
if (status == 0)
{
Console.WriteLine("Added document");
nodeVol = objInfo.toInteger("VolumeID");
nodeID = objInfo.toInteger("ID");
Console.WriteLine("Added document**** details are " + nodeVol + "new nodeID" + nodeID);
}
}
if (status != 0)
{
// Display status code in both integer and hex
System.Console.WriteLine("Status=" + status +
" (0x" + Convert.ToString(status, 16) + ")");
// If the session handle is valid, get the session's error
// information
if (session != null)
{
// Get the error information
int stat = session.getStatus();
string message = session.getStatusMessage();
string errMsg = session.getErrMsg();
string apiError = session.getApiError();
Console.WriteLine("Session failure status is " + stat +
" (0x" + Convert.ToString(stat) + ")");
if (message != "" || errMsg != "" || apiError != "")
{
Console.WriteLine("Message=" + message);
Console.WriteLine("errMsg=" + errMsg);
Console.WriteLine("apiError=" + apiError);
}
}
}
Console.WriteLine("End of sample");
Console.ReadLine();
}
catch (Exception e)
{
// Display exception
Console.WriteLine("Application encountered an exception:");
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
}
}