📄 person.java~29~
字号:
/* 曾海 2003-9-11 用于定义一个加入ldap的类对象。 要加入的话必须实现dircontext接口 作为一个整体加入,加入是用ctx的bind方法 这个类主要实现一些Attribute,比如 getAttributes的各种重载方法*/package jndi;import java.util.*;import javax.naming.*;import javax.naming.directory.*;public class Person extends InitialDirContext{ String type; Attributes myAttrs; public Person(String uid,String givenname,String sn,String ou,String mail) throws NamingException { myAttrs=new BasicAttributes(true); //大小写无关 type=uid; Attribute oc = new BasicAttribute("objectclass"); oc.add("person"); oc.add("top"); Attribute ouSet = new BasicAttribute("ou"); ouSet.add("People"); ouSet.add(ou); myAttrs.put(oc); myAttrs.put(ouSet); myAttrs.put("uid",uid);// myAttrs.put("cn",cn); myAttrs.put("sn",sn); myAttrs.put("givenname",givenname); myAttrs.put("mail",mail); }//cons //总是只返回一个总的东西。 public Attributes getAttributes(String name) throws NamingException{ if (! name.equals("")) throw new NameNotFoundException(); return myAttrs; } public Attributes getAttributes(Name name) throws NamingException{ return getAttributes(name.toString() ); } public String toString(){ return type; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -