在Apache目录服务器中存储Java对象,第2部分:(下) - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-15
ring workContext) { if (uid != null && cn == null) { String[] objClassValues = {"top","person"}; addUserAttribute ("uid", uid); if (commonName != null) addUserAttribute ("cn", commonName); addUserAttributes ("objectClass", objClassValues); try { dirContext.bind(workContext, null, attributes); } catch (NamingException e) { e.printStackTrace(); } } else if (uid == null && cn != null) { addUserAttribute ("cn", cn); try { dirContext.bind(workContext, javaObject, attributes); } catch (NamingException e) { e.printStackTrace(); } } }//store public void addUserAttribute (String name, String value){ Attribute attr = new BasicAttribute(name); attr.add(value); attributes.put(attr); }//addUserAttribute public void addUserAttributes(String name, String[] value) { Attribute attr = new BasicAttribute (name); if (value != null) { for (int i =0; i < value.length; i++) attr.add(value[i]); } attributes.put(attr); }//addUserAttribute public void writeToServer () { connect(); if (userID == null && commonName != null) userID = commonName; //Check if the cn of the Java object is set. //If not, use commonName as object cn. if (javaObject != null) { if (javaObjectCN == null && commonName != null) javaObjectCN = commonName; } if (!(isObjectPresent(userID, null, initialContext))) { workingContext = "uid="+userID+","+initialContext; store(userID, null, workingContext); workingContext = "cn="+javaObjectCN +",uid="+userID+","+initialContext; store( null, javaObjectCN, workingContext); } else if (isObjectPresent(null, javaObjectCN, "uid="+userID+","+initialContext)) { workingContext = "cn="+javaObjectCN +",uid="+userID +","+ initialContext; update(null, javaObjectCN, workingContext); } else { workingContext = "cn="+javaObjectCN +",uid="+userID +","+ initialContext; store(null, javaObjectCN, workingContext); } close(); }//writeToServer() public void searchFromServer(String user, String object) { connect(); NamingEnum |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于在Apache目录服务器中存储Java对象,第2部分:(下) - 编程入门网的所有评论