Hi,
I am writing java code to load users into the Oracle Internet Directory. OID and LDAPs are new to me. On install, one of the directories automatically created in OID was "cn=Users, dc=dex, dc=com". I have able to add employees to that directory with no problem. Now I would like to create a new directory for Vendors. Even though I am logging in as the administrator, I am getting an error message claiming I do not have access privileges. I created a small program that successfully adds a user (so that you know I am at least connecting to OID correctly) and then unsuccessfully attempts to create a Vendor directory. What am I doing wrong?
THE PROGRAM OUTPUT...
Start
Created context
Created user
About to create vendor directory
javax.naming.NoPermissionException: [LDAP: error code 50 - Insufficient Access Rights]; remaining name 'cn=Vendors, dc=dex, dc=com'
javax.naming.NamingException com.sun.jndi.ldap.LdapCtx.mapErrorCode(int, java.lang.String)
void com.sun.jndi.ldap.LdapCtx.processReturnCode(com.sun.jndi.ldap.LdapResult, javax.naming.Name, java.lang.Object, javax.naming.Name, java.util.Hashtable, java.lang.String)
void com.sun.jndi.ldap.LdapCtx.processReturnCode(com.sun.jndi.ldap.LdapResult, javax.naming.Name)
javax.naming.directory.DirContext com.sun.jndi.ldap.LdapCtx.c_createSubcontext(javax.naming.Name, javax.naming.directory.Attributes, com.sun.jndi.toolkit.ctx.Continuation)
javax.naming.directory.DirContext com.sun.jndi.toolkit.ctx.ComponentDirContext.p_createSubcontext(javax.naming.Name, javax.naming.directory.Attributes, com.sun.jndi.toolkit.ctx.Continuation)
javax.naming.directory.DirContext com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(javax.naming.Name, javax.naming.directory.Attributes)
javax.naming.directory.DirContext com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(java.lang.String, javax.naming.directory.Attributes)
javax.naming.directory.DirContext javax.naming.directory.InitialDirContext.createSubcontext(java.lang.String, javax.naming.directory.Attributes)
void com.dex.oidsync.sessionfacade.Sample.main(java.lang.String[])
Process exited with exit code 0.
THE PROGRAM...
package com.dex.oidsync.sessionfacade;
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Hashtable;
public class Sample
{
// OID user attributes
static private final String ATTR_OBJECTCLASS = "objectclass";
static private final String ATTR_EMPLOYEENUMBER = "employeenumber";
static private final String ATTR_GIVENNAME = "givenname";
static private final String ATTR_MAIL = "mail";
static private final String ATTR_MIDDLENAME = "middlename";
static private final String ATTR_USERPASSWORD = "userpassword";
static private final String ATTR_ORCLACTIVESTARTDATE = "orclactivestartdate";
static private final String ATTR_DEPARTMENTNUMBER = "departmentNumber";
static private final String ATTR_SN = "sn";
// OID objectclasses
static private final String CLASS_TOP = "top";
static private final String CLASS_PERSON = "person";
static private final String CLASS_INETORGPERSON = "inetorgperson";
static private final String CLASS_ORCLUSER = "orcluser";
static private final String CLASS_ORGANIZATIONALPERSON = "organizationalperson";
static private final String CLASS_ORCLUSERV2 = "orcluserv2";
static private final String CLASS_ORCLCONTAINER = "orclContainer";
static private final String EMPLOYEE_ID = "1234";
static private final String FIRST_NAME = "Bob";
static private final String MIDDLE_NAME = "A";
static private final String LAST_NAME = "FISH";
static private final String DEPARTMENT = "Sales";
static private final String START_DATE = "20030911000000z";
static private final String EMAIL_ADDR = "bob.fish@company.net";
static private final String USERNAME="testuser1";
static private final String PASSWORD = "password1";
public Sample()
{
}
public static void main(String[] args)
{
try
{
System.out.println("Start"
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"
env.put(Context.PROVIDER_URL, "ldap://infradev.dex.com:4032"
env.put(Context.SECURITY_AUTHENTICATION, "simple"
env.put(Context.SECURITY_PRINCIPAL,"cn=orcladmin, cn=Users, dc=dex, dc=com"
env.put(Context.SECURITY_CREDENTIALS, "secret"
DirContext dirctx = new InitialDirContext(env);
System.out.println("Created context"
Attributes attrs = new BasicAttributes(true);
// setup classes
Attribute objectclass = new BasicAttribute(ATTR_OBJECTCLASS);
objectclass.add(CLASS_TOP);
objectclass.add(CLASS_PERSON);
objectclass.add(CLASS_INETORGPERSON);
objectclass.add(CLASS_ORGANIZATIONALPERSON);
objectclass.add(CLASS_ORCLUSER);
objectclass.add(CLASS_ORCLUSERV2);
attrs.put(objectclass);
// employee number
Attribute employeenumber = new BasicAttribute(ATTR_EMPLOYEENUMBER);
employeenumber.add(EMPLOYEE_ID);
attrs.put(employeenumber);
// first name
Attribute givenname = new BasicAttribute(ATTR_GIVENNAME);
givenname.add(FIRST_NAME);
attrs.put(givenname);
// middle name
Attribute middlename = new BasicAttribute(ATTR_MIDDLENAME);
middlename.add(MIDDLE_NAME);
attrs.put(middlename);
// last name
Attribute sn = new BasicAttribute(ATTR_SN);
sn.add(LAST_NAME);
attrs.put(sn);
// password
Attribute userpassword = new BasicAttribute(ATTR_USERPASSWORD);
userpassword.add(PASSWORD);
attrs.put(userpassword);
// department
Attribute department = new BasicAttribute(ATTR_DEPARTMENTNUMBER);
department.add(DEPARTMENT);
attrs.put(department);
// email
Attribute mail = new BasicAttribute(ATTR_MAIL);
mail.add(EMAIL_ADDR);
attrs.put(mail);
Attribute orclactivestartdate = new BasicAttribute(ATTR_ORCLACTIVESTARTDATE);
orclactivestartdate.add(START_DATE);
attrs.put(orclactivestartdate);
Context result = dirctx.createSubcontext("cn=" + USERNAME
+ ", cn=Users, dc=dex, dc=com", attrs);
System.out.println("Created user"
attrs = new BasicAttributes(true);
// setup classes
Attribute objectclass2 = new BasicAttribute(ATTR_OBJECTCLASS);
objectclass2.add(CLASS_TOP);
objectclass2.add(CLASS_ORCLCONTAINER);
attrs.put(objectclass2);
System.out.println("About to create vendor directory"
result = dirctx.createSubcontext("cn=Vendors, dc=dex, dc=com", attrs);
System.out.println("Vendor directory created"
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
I am writing java code to load users into the Oracle Internet Directory. OID and LDAPs are new to me. On install, one of the directories automatically created in OID was "cn=Users, dc=dex, dc=com". I have able to add employees to that directory with no problem. Now I would like to create a new directory for Vendors. Even though I am logging in as the administrator, I am getting an error message claiming I do not have access privileges. I created a small program that successfully adds a user (so that you know I am at least connecting to OID correctly) and then unsuccessfully attempts to create a Vendor directory. What am I doing wrong?
THE PROGRAM OUTPUT...
Start
Created context
Created user
About to create vendor directory
javax.naming.NoPermissionException: [LDAP: error code 50 - Insufficient Access Rights]; remaining name 'cn=Vendors, dc=dex, dc=com'
javax.naming.NamingException com.sun.jndi.ldap.LdapCtx.mapErrorCode(int, java.lang.String)
void com.sun.jndi.ldap.LdapCtx.processReturnCode(com.sun.jndi.ldap.LdapResult, javax.naming.Name, java.lang.Object, javax.naming.Name, java.util.Hashtable, java.lang.String)
void com.sun.jndi.ldap.LdapCtx.processReturnCode(com.sun.jndi.ldap.LdapResult, javax.naming.Name)
javax.naming.directory.DirContext com.sun.jndi.ldap.LdapCtx.c_createSubcontext(javax.naming.Name, javax.naming.directory.Attributes, com.sun.jndi.toolkit.ctx.Continuation)
javax.naming.directory.DirContext com.sun.jndi.toolkit.ctx.ComponentDirContext.p_createSubcontext(javax.naming.Name, javax.naming.directory.Attributes, com.sun.jndi.toolkit.ctx.Continuation)
javax.naming.directory.DirContext com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(javax.naming.Name, javax.naming.directory.Attributes)
javax.naming.directory.DirContext com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(java.lang.String, javax.naming.directory.Attributes)
javax.naming.directory.DirContext javax.naming.directory.InitialDirContext.createSubcontext(java.lang.String, javax.naming.directory.Attributes)
void com.dex.oidsync.sessionfacade.Sample.main(java.lang.String[])
Process exited with exit code 0.
THE PROGRAM...
package com.dex.oidsync.sessionfacade;
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Hashtable;
public class Sample
{
// OID user attributes
static private final String ATTR_OBJECTCLASS = "objectclass";
static private final String ATTR_EMPLOYEENUMBER = "employeenumber";
static private final String ATTR_GIVENNAME = "givenname";
static private final String ATTR_MAIL = "mail";
static private final String ATTR_MIDDLENAME = "middlename";
static private final String ATTR_USERPASSWORD = "userpassword";
static private final String ATTR_ORCLACTIVESTARTDATE = "orclactivestartdate";
static private final String ATTR_DEPARTMENTNUMBER = "departmentNumber";
static private final String ATTR_SN = "sn";
// OID objectclasses
static private final String CLASS_TOP = "top";
static private final String CLASS_PERSON = "person";
static private final String CLASS_INETORGPERSON = "inetorgperson";
static private final String CLASS_ORCLUSER = "orcluser";
static private final String CLASS_ORGANIZATIONALPERSON = "organizationalperson";
static private final String CLASS_ORCLUSERV2 = "orcluserv2";
static private final String CLASS_ORCLCONTAINER = "orclContainer";
static private final String EMPLOYEE_ID = "1234";
static private final String FIRST_NAME = "Bob";
static private final String MIDDLE_NAME = "A";
static private final String LAST_NAME = "FISH";
static private final String DEPARTMENT = "Sales";
static private final String START_DATE = "20030911000000z";
static private final String EMAIL_ADDR = "bob.fish@company.net";
static private final String USERNAME="testuser1";
static private final String PASSWORD = "password1";
public Sample()
{
}
public static void main(String[] args)
{
try
{
System.out.println("Start"
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"
env.put(Context.PROVIDER_URL, "ldap://infradev.dex.com:4032"
env.put(Context.SECURITY_AUTHENTICATION, "simple"
env.put(Context.SECURITY_PRINCIPAL,"cn=orcladmin, cn=Users, dc=dex, dc=com"
env.put(Context.SECURITY_CREDENTIALS, "secret"
DirContext dirctx = new InitialDirContext(env);
System.out.println("Created context"
Attributes attrs = new BasicAttributes(true);
// setup classes
Attribute objectclass = new BasicAttribute(ATTR_OBJECTCLASS);
objectclass.add(CLASS_TOP);
objectclass.add(CLASS_PERSON);
objectclass.add(CLASS_INETORGPERSON);
objectclass.add(CLASS_ORGANIZATIONALPERSON);
objectclass.add(CLASS_ORCLUSER);
objectclass.add(CLASS_ORCLUSERV2);
attrs.put(objectclass);
// employee number
Attribute employeenumber = new BasicAttribute(ATTR_EMPLOYEENUMBER);
employeenumber.add(EMPLOYEE_ID);
attrs.put(employeenumber);
// first name
Attribute givenname = new BasicAttribute(ATTR_GIVENNAME);
givenname.add(FIRST_NAME);
attrs.put(givenname);
// middle name
Attribute middlename = new BasicAttribute(ATTR_MIDDLENAME);
middlename.add(MIDDLE_NAME);
attrs.put(middlename);
// last name
Attribute sn = new BasicAttribute(ATTR_SN);
sn.add(LAST_NAME);
attrs.put(sn);
// password
Attribute userpassword = new BasicAttribute(ATTR_USERPASSWORD);
userpassword.add(PASSWORD);
attrs.put(userpassword);
// department
Attribute department = new BasicAttribute(ATTR_DEPARTMENTNUMBER);
department.add(DEPARTMENT);
attrs.put(department);
Attribute mail = new BasicAttribute(ATTR_MAIL);
mail.add(EMAIL_ADDR);
attrs.put(mail);
Attribute orclactivestartdate = new BasicAttribute(ATTR_ORCLACTIVESTARTDATE);
orclactivestartdate.add(START_DATE);
attrs.put(orclactivestartdate);
Context result = dirctx.createSubcontext("cn=" + USERNAME
+ ", cn=Users, dc=dex, dc=com", attrs);
System.out.println("Created user"
attrs = new BasicAttributes(true);
// setup classes
Attribute objectclass2 = new BasicAttribute(ATTR_OBJECTCLASS);
objectclass2.add(CLASS_TOP);
objectclass2.add(CLASS_ORCLCONTAINER);
attrs.put(objectclass2);
System.out.println("About to create vendor directory"
result = dirctx.createSubcontext("cn=Vendors, dc=dex, dc=com", attrs);
System.out.println("Vendor directory created"
}
catch (Exception e)
{
e.printStackTrace();
}
}
}