Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to programmatically add users to group using the API

Status
Not open for further replies.

Cabous

Programmer
Apr 10, 2006
1
ZA
Hi all;
We are running Microsoft AD in my company and the authentication and synchronisation bit works fine to LiveLink.

I would like some help on how to code a function which allows me to add users to a group within LiveLink based on an export received from our SAP system.

The problem is that although the usernames are synced with the Exchange server, the group members on the Exchange server are not up to date. The most up to date information is the plain text export from SAP.

The code should be scheduled to run once a day as well.

Thanks


Blessings to all
 
Do not know what flavor of prog language you were looking,but here is a quick and dirty sample in java,which is my favorite.This should fairly work in C# too.I used textpad to write this and my livelink is one that does not have domain(livelink domains) support.The scheduling part of this code can be done by creating a batch file or pointing this class file to your scheduler.Hope this helps
Listing of addUserToGroup.java
Code:
/*******************[URL unfurl="true"]http://www.nairkn,com*************************************[/URL]
***The code albeit hard coded uses the livelink java api
***for creating a category and populating its contents
***Written for  Dr LAPI series in
***[URL unfurl="true"]http://www.greggriffiths.org/livelink/development/lapi/drlapi/[/URL]
***java version "1.4.2_05"
***Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
***Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
***Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
***Oracle 32-bit Windows: Version 8.1.7.0.0
***Livelink 9.1.0 SP3
***@author K N Nair (appoos@hotmail.com) alias appnair
*** in tek-tips forum [URL unfurl="true"]http://www.tek-tips.com/tipmasters.cfm?pid=862[/URL]
***The published documentation of Opentext,livelink are proprietary
***software and given proper credits
*/

/*When using a package create a hierarchy called com/nairkn
and put the source file there and after compilation
execute it by calling java com.nairkn.addUserToGroup
Error traps at each stage should be done by looking at
the status of each LAPI call for clarity I have omitted those
*/

import com.opentext.api.*; //If you are ajar person the right jars
public class addUserToGroup
{
	// Declare some constants for the user and group to add
	// In production, your code would read a file where this information is stored.
	public static final String USER_NAME = "Admin";
	public static final String USER_PASS = "Admin";


	public static void main( String[] args )
	{
		try
		{
			// Declare some local fields
			LLSession	session;
			int			status;

			session = new LLSession( "localhost", 2099, "", "Admin", "Admin" );
			LAPI_USERS		users = new LAPI_USERS( session );

/*here is the user API prototype we will be using to do that
 we need a user from the system ,their loginname(select name from kuaf where id=1000)
 should give 'Admin'.In this case I am going to add a user called 'asha' to the
'DefaultGroup'.NOTE:the user 'asha is already existing in my system with
 another base group
 public   int    AddUserToGroup (
			                     String      user,
			                     int         toType,
			                     String      toName)

	READ THE DOCUMENTATION OF THE API FOR THE CONSTANTS	                     */





			status = users.AddUserToGroup("asha",LAPI_USERS.GROUP,"DefaultGroup" );
			//THIS IS ANOTHER WAY
			//status = users.AddUserToGroup("asha",users.GROUP,"Controlled" );

			if ( status != 0 )
			{
				String statustext = session.getStatusMessage();
				String errtext = session.getErrMsg();
				String apitext = session.getApiError();
				System.out.println( "\nERROR: " + statustext + "\n" + errtext + "\n" + apitext );
			} else {
				System.out.println( "\nSUCCESS: New HARD CODED user " +  " has been added" );
			}
		}
		catch ( Throwable e )
		{
			String x = e.getClass().getName();
			String s = e.getMessage();
			e.printStackTrace();
		}
	}  // end main
}

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top