Search code examples
active-directorytibco-business-works

LDAP authentication with REST calls in Tibco BW 5.12?


Can we implement LDAP authentication with REST calls in Tibco BW 5.12. I was trying to find but couldnt find anything in documentation. If yes, can someone please explain the process to do so.


Solution

  • Tibco Designer for BW 5.12 is not providing REST API palette by default but you can use REST plugin https://docs.tibco.com/products/tibco-activematrix-businessworks-plug-in-for-rest-and-json-1-1-1 (require a separate license purchase). Please note that you may need to fix the bug TIBCO BW - ERROR , Can not open Project (REST and JSON Plugin)

    Here is tutorial for REST API using tibco "REST & JSON Palette" http://tutorialspedia.com/develop-restful-web-service-in-tibco-step-by-step-tutorial/

    LDAP REST API integration implementation will depend on your LDAP server vendor.

    If the client is in intranet another option is to use LDAP protocol directly from java using "Java Code" action

    enter image description here

        org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("bw.logger");
        logger.info("START LDAP Connection");
        LdapContext ctx = null;
        try {
            Hashtable<String, String> env = new Hashtable<String, String>();
            env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
            env.put(Context.SECURITY_AUTHENTICATION, "Simple");
            env.put(Context.SECURITY_PRINCIPAL,  "[email protected]");
            env.put(Context.SECURITY_CREDENTIALS, "Password");
            env.put(Context.PROVIDER_URL, "ldap://ldap.test.com:389");
            ctx = new InitialLdapContext(env, null);
            logger.info("Connection Successful.");
        } catch (NamingException nex) {
            logger.info("LDAP Connection: FAILED\n" + nex.getMessage(), nex);
        }
    

    please note that you need to add imports. Full class:

    package Processes.TestProcess.LDAPcall;
    import java.util.*;
    import java.io.*;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Hashtable;
    import java.util.List;
    import java.util.Map;
    
    import javax.naming.Context;
    import javax.naming.NamingEnumeration;
    import javax.naming.NamingException;
    import javax.naming.directory.Attributes;
    import javax.naming.directory.SearchControls;
    import javax.naming.directory.SearchResult;
    import javax.naming.ldap.InitialLdapContext;
    import javax.naming.ldap.LdapContext;
    public class LDAPcallJavaCode{
    /****** START SET/GET METHOD, DO NOT MODIFY *****/
    /****** END SET/GET METHOD, DO NOT MODIFY *****/
        public LDAPcallJavaCode() {
        }
        public void invoke() throws Exception {
    /* Available Variables: DO NOT MODIFY
    * Available Variables: DO NOT MODIFY *****/
            org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("bw.logger");
            logger.info("START LDAP Connection");
            LdapContext ctx = null;
            try {
                Hashtable<String, String> env = new Hashtable<String, String>();
                env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
                env.put(Context.SECURITY_AUTHENTICATION, "Simple");
                env.put(Context.SECURITY_PRINCIPAL,  "[email protected]");
                env.put(Context.SECURITY_CREDENTIALS, "Password");
                env.put(Context.PROVIDER_URL, "ldap://ldap.test.com:389");
                ctx = new InitialLdapContext(env, null);
                logger.info("Connection Successful.");
            } catch (NamingException nex) {
                logger.info("LDAP Connection: FAILED\n" + nex.getMessage(), nex);
            }}
    }