Java DirContext create sub context

Description

Java DirContext create sub context


//AddEntry.java // www.  j  a  v a2s. c o  m
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

public class Main {
   public static void main(String args[]) {
      try {
         DirContext ctx = new InitialDirContext();
         Attributes attrs = new BasicAttributes(true);
         attrs.put(new BasicAttribute("objectclass", "country"));
         ctx.createSubcontext(args[0], attrs);
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}



PreviousNext

Related