我正在尝试通过java中的ldap在Windows Active Directory中创建活动用户。
我的创作方法是:
private Attributes createUserAttributes(String userName, String firstName, String lastName, String password) {
Attributes container = new BasicAttributes();
Attribute objClasses = new BasicAttribute("objectClass");
Attribute userPassword = new BasicAttribute("userPassword", password);
Attribute sAMAccountName = new BasicAttribute("SAMAccountName", userName);
Attribute userPrincipialAttribute = new BasicAttribute("userPrincipalName", userName + "@" + DOMAIN_NAME);
Attribute firstNameAttribute = new BasicAttribute("givenName", firstName);
Attribute secondNameAttribute = new BasicAttribute("sn", lastName);
Attribute activatedAccount = new BasicAttribute("userAccountControl", "512");
objClasses.add("user");
// Add these to the container
container.put(objClasses);
container.put(userPassword);
container.put(sAMAccountName);
container.put(userPrincipialAttribute);
container.put(firstNameAttribute);
container.put(secondNameAttribute);
container.put(activatedAccount);
return container;
}
Unfornutntly我收到以下错误:
Exception in thread "main" javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 0000052D: SvcErr: DSID-031A120C, problem 5003 (WILL_NOT_PERFORM), data 0
有没有想法?
答案 0 :(得分:1)
这有助于解答您的问题Thread: Operation Not Supported Exception in JNDI/Active Directory How to add an active user account to Active Directory。
答案 1 :(得分:1)
我遇到的问题是密码相关性。使用弱密码,显示相同的消息。验证在AD上定义的规则是什么。