今天心情很不爽,不扯别的啦,来讲讲Ldap对AD域账户的操作吧!至于Ldap和ad今天就不做详细解释了,有兴趣的朋友可以看看上一篇博文,里面有详细的介绍!直接上代码:
/**
* @Description:
*
* @Title: LdapByUser.java
* @Package com.joyce.ad
* @Copyright: Copyright (c) 2014
*
* @author Comsys-LZP
* @date 2014-8-8 上午10:39:35
* @version V2.0
*/
package com.joyce.ad;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
/**
* @Description:
*
* @ClassName: LdapByUser
* @Copyright: Copyright (c) 2014
*
* @author Comsys-LZP
* @date 2014-8-8 上午10:39:35
* @version V2.0
*/
public class LdapByUser {
DirContext dc = null;
String root = "DC=2003,DC=com"; // LDAP的根节点的DC
/**
* @Description: 程序主入口
*
* @param args
*
* @Title: LdapByUser.java
* @Copyright: Copyright (c) 2014
*
* @author Comsys-LZP
* @date 2014-8-11 上午10:27:15
* @version V2.0
*/
public static void main(String[] args) {
LdapByUser ldap = new LdapByUser();
// ldap.delete("CN=涛涛,OU=研发部,DC