Wednesday, April 13, 2022

LDAPConnection suing Java Code

import java.util.Hashtable;

import javax.naming.Context;

import javax.naming.NamingException;

import javax.naming.ldap.InitialLdapContext;

import javax.naming.ldap.LdapContext;


public class LdapConnection {

     public static void main(String[] args) {

          Hashtable env = new Hashtable();

          env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

          env.put(Context.PROVIDER_URL,"ldap://localhost:389");

          try {

               LdapContext ctx = new InitialLdapContext(env,null);

               System.out.println("LDAP Connection Successful");

               System.exit(0);

          } catch (NamingException e) {

               System.err.println("LDAP Notifications failure. " + e.getMessage());

               System.exit(1);

          }

      }

}

No comments:

Post a Comment

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...