Connecting to LDAP

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

BIDSDEV
Premium Member
Premium Member
Posts: 12
Joined: Tue Nov 27, 2012 3:33 am
Location: India

Connecting to LDAP

Post by BIDSDEV »

Hi All,

We have a requirement to get data from LDAP server via Datastage.

What are the steps that needs to be followed to get data from LDAP?

Is there any plug in in Datastage 8.7 for this task


I have gone through some of the posts here and couldn't get much out of them

Can you please guide me

Regards
Aj
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Hi,
We are connecting to LDAP through Java Client stage in V8.0 in our project.
Properties to mention :
1. Transformer class name
2. Users properties
a) ldap driver
b) ldap connection URL
c) ldap user
d) ldap password
e) ldap sql
3. Java library path in JVM options.
BIDSDEV
Premium Member
Premium Member
Posts: 12
Joined: Tue Nov 27, 2012 3:33 am
Location: India

Post by BIDSDEV »

Hi Vinod,

Thanks for the message.

I don't have any of the below details apart from leap user name and password

I have also never used Java client

Do we need to install any Java packages in this

Regards
Ram
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I think the first thing you need to do is to find an LDAP administrator on site from whom you can obtain these details. A Java practitioner would be a good find also. Your lack of experience is telling; learn from those experts.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
BIDSDEV
Premium Member
Premium Member
Posts: 12
Joined: Tue Nov 27, 2012 3:33 am
Location: India

Post by BIDSDEV »

Hi All,

sorry for delay in response

Actually i didn't find a resource from client side who can help me with this task

Unfortunately i couldn't get any Java resource to get this right. ( My lack of Java experience is also closing the doors)

I was looking at some of the older posts and they refer to using the commands -- csvde ,ldapsearch

Can you please guide to query ldap data from Datastage by uisng a DSN OR by using ldapsearch

please guide me the best approach

Regards
Aj
BIDSDEV
Premium Member
Premium Member
Posts: 12
Joined: Tue Nov 27, 2012 3:33 am
Location: India

Post by BIDSDEV »

Hi All,

I found the below ways to connect to "LDAP" and fetch files

1. Use a third-party ODBC driver to access your LDAP server
2. Use a Java Stage in the Designer client to use Java Naming and Directory Interface (JNDI) to pull data from the LDAP enabled directories. The Java Stage is part of the Java Pack, which is an add-on product.
3. Create a LDAP search script using the LDAPsearch command. You can then call this script using the ExecSH(in the Job Properties) and redirect the output to a file which can then be read into DataStage Designer.
I would like to try option 1 , to create an DSN to fetch the files from AD

Is there any specific syntax for this and should this also be updated in odbc.ini ?

Please share your ideas

Regards
Aj
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

First things first...

Did you acquire a 3rd party ODBC driver to access your LDAP source?

You can't configure something that doesn't exist.

Mike
BIDSDEV
Premium Member
Premium Member
Posts: 12
Joined: Tue Nov 27, 2012 3:33 am
Location: India

Post by BIDSDEV »

Hi Mike,

Thanks for the reply

Can you please let me know from where can i get third party ODBc driver (Do I need to get that from LDAP admin )

Thanks
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Sorry, I can't help you with specifics since I have not gone down that path before.

Talking to your LDAP admin is probably a good place to start... you need to find out what vendor is the supplier of your directory service. Then I would see if that vendor provides an ODBC driver... Next would be a google search to see if there are any other ODBC driver providers for your directory service.

Be prepared to fork over some $ unless you're lucky enough to find an open source solution.

Mike
BIDSDEV
Premium Member
Premium Member
Posts: 12
Joined: Tue Nov 27, 2012 3:33 am
Location: India

Post by BIDSDEV »

Thanks Mike

I will speak to my LDAP admin on Monday.

I will also try for other means of solving this

Can I get any suggestion to deal this comfortably

( I was given a suggestion to use Java class, but I don't have any experience in writing that Java class )


Regards
Aj
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

As has been noted above in various replies, you need one or more of the following:

a) someone at your company, who is responsible for LDAP, to research available (if any) ODBC drivers. You can't easily do this yourself--- it needs to be someone who is very close to the LDAP environment at your site, who knows the vendor, provider and can assist with this research and activity

b) someone at your company who is aware of LDAP and also of Java and knows how to read LDAP with Java. It should be an experienced Java person. The company needs to hire that person or find such a person to assist in DataStage integration using JavaPack, which (in general) is documented in many places here in the forum, the formal documentation, and elsewhere on the web.

You can't do this one alone without the skills above unless you have lots of time for research, testing, playing, etc.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
BIDSDEV
Premium Member
Premium Member
Posts: 12
Joined: Tue Nov 27, 2012 3:33 am
Location: India

Post by BIDSDEV »

Hi All,

With the help from one of my Java associate , we have managed to get the Java code to connect to Active Directory.

Below is the code which tests the connection to Active Directory

Code: Select all

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

import com.ascentialsoftware.jds.Row;
import com.ascentialsoftware.jds.Stage;


public class TestConnection extends Stage{

	private int isInitialized = 0;
	@Override
	public void initialize() {
				
	}

	@Override
	public int process() {
		info("******** inside process");
		if(isInitialized == 1 ){
			return OUTPUT_STATUS_END_OF_DATA;
		}
		try {
			info("******** inside try");
			DirContext dctx = new InitialDirContext(getEnvironment());
			info("******** Established connection");
			dctx.close();
			 Row  outputRow    =  createOutputRow();
			 outputRow.setValueAsString(0,"Connected");
			 writeRow(outputRow);
			 isInitialized++;
			 return OUTPUT_STATUS_READY;
	        
		} catch (Exception e) {
			fatal("Error while connecting");
			return OUTPUT_STATUS_END_OF_DATA;
		}
	}

	@Override
	public void terminate() {
		// TODO Auto-generated method stub
		super.terminate();
	}
		
	private static Hashtable getEnvironment() {
		Hashtable environmet= new Hashtable(11);
		environmet.put(Context.SECURITY_PRINCIPAL,"USERNAME");//User
		environmet.put(Context.SECURITY_CREDENTIALS, "PASSWORD");//Password
		environmet.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
		environmet.put(Context.PROVIDER_URL,"ldap://URL:389");
		environmet.put("com.sun.jndi.ldap.connect.pool", "true");
		return environmet;
	}
	
	
	public static void main(String[] args)throws Exception{
		
		DirContext dctx = new InitialDirContext(getEnvironment());
		System.out.println("Connected Successfully");
		dctx.close();
		
	}
	
	
	
	

}
The Issue here is sometimes the Job sexecutes succesfully and sometimes it doesn't

It doesn't give me proper error message when it fails also and below is FATAL message i get
Java_Client,0: Failure during execution of operator logic.
My Job design is : Java Client Stage ----> Sequential File Stage

Under Java Client Stage, I have my Transformer class name and path of it under Users's Class Path
and i Haven't passed any values under Java Virtual Machine Options

Can any one of you please guide me to resolve this / identify what the root cause for this problem

Regards
Aj
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

I can only guess at the moment....it certainly seems like you have included the necessary methods. Do you have any simpler samples that work all the time? There is sample code at my blog (see below)....does that work? When you say it works "sometimes".....what is different?

One "maybe" issue is the info calls and other warning or fatal calls I'd you use them. Comment them all out. I have seen instances when any of the log features caused issues.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
BIDSDEV
Premium Member
Premium Member
Posts: 12
Joined: Tue Nov 27, 2012 3:33 am
Location: India

Post by BIDSDEV »

Hi Ernie,

This is our First Java program that we are calling from DataStage

I tried searching your blog, to find a sample code that connects to Active directory , but couldn't find it

Can you please guide me to find the sample code for AD

When i say it works sometimes- It happened to me that when we run the job for the first time it executes perfectly and when we run it there after it fails

I will also try removing the Info calls and see if it helps

Regards
Aj
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There's no call to Terminate in your TestConnection class.

This may explain why the second attempt to connect fails.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply