Creating a user account in AD using JNDI and minimum password age

So, I want to create a user account in Windows 2003 using Active Directory using JNDI. I follow the following example: http://forums.sun.com/thread.jspa?threadID=582103 (first post). The following code raises an LDAP error, which I believe is due to a chicken and egg problem when creating a user and then setting a password that is limited to a minimum password time of 1 day.

//Replace the "unicdodePwd" attribute with a new value
//Password must be both Unicode and a quoted string
String newQuotedPassword = "\"Password2000\"";
byte[] newUnicodePassword = newQuotedPassword.getBytes("UTF-16LE");

mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("unicodePwd", newUnicodePassword));
mods[1] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("userAccountControl",Integer.toString(UF_NORMAL_ACCOUNT + UF_PASSWORD_EXPIRED)));

// Perform the update
ctx.modifyAttributes(userName, mods);
System.out.println("Set password & updated userccountControl");

I get the error code Ldap: 53 problem 5003 (cannot execute) when it tries to set a password, which I believe is the minimum password age. What is really strange is that if I go to the active directory of users and computers as a domain administrator, I also can’t set a password. The only way I can change it is to select the reset password option and then enable "the user must change the account the next time he logs in." After that, I can set the password both programmatically and through a graphical interface.

, , , . , 5003.

- JNDI Windows 2003? .

+3
2

Java AD.

, : - "" AD:

  • LDAP
  • / , SSH.

, Java- AD "https://..." SSH JNDI. : http://java.sun.com/products/jndi/tutorial/ldap/security/ssl.html

// Specify SSL
env.put(Context.SECURITY_PROTOCOL, "ssl");
+1

SSL- unicodePwd

. :

https://msdn.microsoft.com/en-us/library/cc223248.aspx

Windows 2000 , 128- ( ) SSL/TLS- DC, . Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2 Windows Server 2016 DC unicodePwd , 128- ( ) - (SASL), SSL/TLS.

0

Source: https://habr.com/ru/post/1765318/


All Articles