You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by sahul <vs...@gowebtop.com> on 2009/08/19 09:35:02 UTC
about my setJndiprops() method
Stefan Zoerner-2 wrote:
>
> Hi,
>
> can you explain, what your
>
> Hashtable env=JndiProps.setJndiProps();
>
> method exactly does?
> To me it is even unclear, why the first binds are successful ...
>
> Greetings from Hamburg,
> Stefan
>
>
> sahul wrote:
>> Hello one and All....
>>
>> I am new to ldap programming. I am using Apache Directory server. I have
>> to
>> insert organization information in apache directory server using jndi
>>
>> from java application. I able to insert the cn node from java
>> application.
>> If I try to insert organization or organization unit level node from java
>>
>> application schema violation error is comming. Please tell me the code to
>> insert organization node from java application. Please help me. very
>>
>> Urgent.
>>
>> If this is the wrong place to post this question atleast please tell me
>> the
>> forum topic where i need to post this question....
>> And my code is
>>
>>
>>
>> public class JndiAppOne
>> {
>> public static void main(String[] args)
>> {
>> Hashtable env=JndiProps.setJndiProps();
>> try
>> {
>> Context ctx = new InitialContext(env);
>> ctx.bind("cn=NUM337,o=mst,ou=system",new Integer(49));
>> ctx.bind("cn=userinfo420,o=mst,ou=system",new
>> User("testname4","testdept4"));
>> ctx.close();
>> }
>> catch (NamingException e)
>> {
>> System.out.println(">>>>>>Operation failed: " + e);
>> e.printStackTrace();
>> }
>> }
>>
>>
>>
>>
>> The above code is working fine.
>>
>> The bind statement in the above code creates a node cn=num337 under the
>> o=mst organization node.
>> I mannually created the o=mst organization level node from ApacheDS
>> studio(ldap client).
>>
>> Problem I am facing:
>>
>> when i try to add o=mst organization node from java applicatin schema
>> violation exception is comming the code is given below
>>
>> ctx.bind("o=MMMMM,ou=system",new User("aaaa","mmmmm"));
>> javax.naming.directory.SchemaViolationException: [LDAP: error code 65 -
>> OBJECT_CLASS_VIOLATION: failed for Add Request]
>>
>>
>>
>> Please help me..very urgent.. I have to create an organization
>> information
>> in ApacheDS from java application
>
>
>
>
=====================AUGUST 19th 2009===================
Hello Mr. Stefan Zoerner
Thank you for replying.....
JndiProps is my user defined class. In that class setJndiProps() is a static
method I used to set the jndi properties in hashtable. The code is given
below:
public class JndiProps
{
public static Hashtable setJndiProps()
{
Hashtable<String,Object> env=new Hashtable<String,Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:10389/");
env.put(Context.SECURITY_PRINCIPAL,"uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS,"secret");
return env;
}
}
Problem I am facing: I am able to insert "cn" node under an organization
node(i created "organization" node explicitly from ldap client browser). If
i try to create "organization" or "organizationUnit" node from java
application SCHEMA VIOLATION EXCEPTION is coming. The bind method I use to
create organization is:
ctx.bind("o=mst,ou=system",new Integer(49));//it is not working
that is i want to create an organization named MST under the (ou=system)
--
View this message in context: http://www.nabble.com/Please-help-me-on-ldap-jndi-programming-tp25026099p25039221.html
Sent from the Apache Directory Project mailing list archive at Nabble.com.