Java DirContext remove attribute

Description

Java DirContext remove attribute

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 {//from   ww  w  .j  a  v a2 s .  c  o m
         DirContext ctx = new InitialDirContext();
         Attributes attrs = new BasicAttributes(true);
         attrs.put(new BasicAttribute(args[1]));
         ctx.modifyAttributes(args[0], DirContext.REMOVE_ATTRIBUTE, attrs);
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}



PreviousNext

Related