title: How to change the "userPassword" attribute of active directory use java jndi ？
body: <p>Our system need to connect to AD for create user , change user password. I can create user success and I can change other attributes successful. But if I change the error of javax.naming.NoPermissionException .</p>
  <p>update pwd function:</p>
  <pre><code>public boolean updateAdPasswordForStudent(Student student) {
          if (!studentExistOnAD(student)) {
              return createAdAccountForStudent(student);
          }
  
          try {
  
              ModificationItem[] mods = new ModificationItem[1];
              mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(&quot;userPassword&quot;, student.getPassword()));
  
  
              ldapConnection.modifyAttributes(&quot;cn=&quot; + student.getStudentNum() + baseDirectoryOfStudent, mods);
          } catch (Exception e) {
              e.printStackTrace();
              log.error(&quot;Failed update AD password for student {}.&quot;, student.getStudentNum());
          }
  
          return false;
      }
  </code></pre>