OIM LDAP OID/OUD/OVD Connection API

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.massiveGaze.ldap;

import java.io.FileInputStream;
import java.util.Hashtable;
import java.util.Properties;

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

public class LDAPConnection {

 static String oidUrl,oidUserName,oidPassword,userContainer;
    private static final String TEST_PROPERTIES_FILE = "data/ldapsync.properties";
    static{
 System.out.println("Connection Started ");
  try{
   Properties eventProps = new Properties();
   eventProps.load(new FileInputStream(TEST_PROPERTIES_FILE));
     oidUrl = eventProps.getProperty("LDAP.OID.URL");
             oidUserName = eventProps.getProperty("LDAP.OID.Username");
             oidPassword = eventProps.getProperty("LDAP.OID.Password");
             userContainer = eventProps.getProperty("LDAP.UserContainer");
             System.out.println("oidUrl- > "+oidUrl);
             System.out.println("oidUserName- > "+oidUserName);
             System.out.println("userContainer- > "+userContainer);
   
  }catch(Exception e){
   System.out.println("Connection Failed With Exception ");
   e.printStackTrace();
  }
}
 public static DirContext getLDAPConnection() throws Exception {
  Hashtable<String,String> attrs = new Hashtable<String,String>();
        attrs.put(Context.PROVIDER_URL, oidUrl);
        attrs.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
  attrs.put(Context.SECURITY_PRINCIPAL, oidUserName);
  attrs.put(Context.SECURITY_CREDENTIALS, oidPassword);
  DirContext context = new InitialDirContext(attrs);
  return context;
    }
 public static String getUserContainer(){
  return userContainer;
 }
 
}

No comments:

Post a Comment

About OIM

Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...

Popular Posts