int UF_ACCOUNTDISABLE = 0x0002;
int UF_PASSWD_NOTREQD = 0x0020;
int UF_PASSWD_CANT_CHANGE = 0x0040;
int UF_NORMAL_ACCOUNT = 0x0200;
int UF_DONT_EXPIRE_PASSWD = 0x10000;
int UF_PASSWORD_EXPIRED = 0x800000;
Attributes attributes = new BasicAttributes(true); Attribute attribute = new BasicAttribute("objectclass"); attribute.add("top"); attribute.add("person"); attribute.add("user"); attributes.put(attribute); attributes.put("mail", "zhuinfo@163.com"); attributes.put("description", "12345"); attributes.put("telephoneNumber", "13012344321"); attributes.put("sAMAccountName", "zhangsan"); attributes.put("cn", "张三"); attributes.put("sn", "张"); attributes.put("givenName", "三"); attributes.put("userPrincipalName", "zhangsan@umapad.com"); attributes.put("userAccountControl", Integer.toString(UF_DONT_EXPIRE_PASSWD+UF_NORMAL_ACCOUNT+UF_PASSWD_NOTREQD)); context.createSubcontext("CN=张三,CN=Users,DC=umapad,DC=com", attributes);