What type of object is being returned? On 9/26/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi, > > I am trying to write a Java object into the directory server. Now > according to the URL > http://java.sun.com/products/jndi/tutorial/objects/storing/ > there are at > least three approaches to do this. The one I have opted is to use Java > serializable objects. Now I believe that my serialization works fine > because I have serialized the object in question and then deserialized > it. I have made the necessary checks like whether the object serialized > is the same as the one deserilized. > > My biggest problem is in writing the serialized object into the > directory server. According to the literature I need a Directory Context > type (Interface DirContext) and the necessary attributes for the > serialized object to be able to do this. My attempt is as follows: > > public DirContext getDirContext(String bindDN, String bindPassword) > throws NamingException { > Hashtable env = new Hashtable(); > env.put(Context.INITIAL_CONTEXT_FACTORY, > "com.sun.jndi.ldap.LdapCtxFactory"); > env.put(Context.PROVIDER_URL, > "ldap://MMatyila_PIV.mrc.ac.za:389/"); > env.put(Context.SECURITY_AUTHENTICATION, "Simple"); > env.put(Context.SECURITY_PRINCIPAL, bindDN); > env.put(Context.SECURITY_CREDENTIALS, bindPassword); > DirContext ctx = new InitialDirContext(env); > return ctx; > } > > for the directory context, and for the necessary attributes for the > serialized object I have: > > public BasicAttributes getSerializationAttributes(String > className, > String serializedData) { > BasicAttributes attrs = new BasicAttributes(true); > > attrs.put("objectclass", "top"); > attrs.put("objectclass", "javaObject"); > attrs.put("objectclass", "javaserializedobject"); > > attrs.put("javaclassname", className); > attrs.put("javaserializeddata", serializedData); > > return attrs; > } > > Now when I read this object from the directory serve I get an object > which I cannot cast to anything sensible. I am not sure where exactly my > problem lies but I would appreciate any assistance. > > Regards, > Muzi Matyila > Medical Research Council, Cape Town > South Africa >
-- Brian Silberbauer Consultant +27 (0)83 566 2705 skype: brian.silberbauer
