[Date Prev][Date Next] [Chronological] [Thread] [Top]

[java] Mixing inetOrgPerson and java objects in one entry (solved)



To answer my own question, this is how it worked out:

Integer i = new Integer( 28420 );
final static String newContext =
"cn=Treborc,o=Magna,c=US";
  BasicAttribute objClasses = new
BasicAttribute("objectclass");
    objClasses.add("person");
    objClasses.add("organizationalPerson");
    objClasses.add("inetOrgPerson");
    BasicAttribute obj2 = new
BasicAttribute("objectclass");
    obj2.add("top");
    obj2.add("javaContainer");
    obj2.add("javaObject");
    obj2.add("javaSerializedObject");
    BasicAttributes attrs = new BasicAttributes();
    attrs.put(objClasses);
    attrs.put("cn","Treborc");
    attrs.put("sn","Iksrazal");
    attrs.put("ou","hello_world");
    attrs.put("userpassword","24 Bytes wss DESede
key!");
    try
    {
      // obtain initial directory context using the
environment
      DirContext ctx = new InitialDirContext( env );
      ctx.bind(newContext, i, attrs);
      Integer  i2 = (Integer)  ctx.lookup(newContext);
      System.err.println("Integer = " + i2);
    }

iksrazal
--- trebor iksrazal <iksrazal@yahoo.com> wrote:
> I can do the following seperately: 
> 
> Add inetOrgPerson: 
> 
> final static String newContext =
> "cn=Trebor,o=Magna,c=US";
> BasicAttribute objClasses = new
> BasicAttribute("objectclass");
>     objClasses.add("person");
>     objClasses.add("organizationalPerson");
>     objClasses.add("inetOrgPerson");
> 
>     BasicAttributes attrs = new BasicAttributes();
>     attrs.put(objClasses);
>     attrs.put("cn","Trebor");
>     attrs.put("sn","Iksrazal");
>     attrs.put("ou","hello_world");
>     attrs.put("userpassword","24 Bytes wss DESede
> key!");
>     attrs.put("userCertificate;binary", userCert);
> 
>     ctx.createSubcontext( newContext, attrs );
> 
> Add java object: 
> 
> Integer i = new Integer( 28420 );
> ctx.bind("cn=OBJ2,o=Magna,c=US", i);
> 
> How might I be able to do both as one dn entry? I
> guess I'm asking how to mix the correct attributes. 
> 
> iksrazal
> 

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you?re looking for faster
http://search.yahoo.com