3 Replies Latest reply: Mar 11, 2013 4:34 PM by EJP RSS

    Saving the password of a user in active directory using java

    996011
      Hello, i am trying to use java to build a class that creates a user in Active directory 2012.But the problem is that when the user is created the password is not being saved.

      Can anybody help on this knowing that i tried to save in the fields userPassword and unicodePwd.

      Thanks.
        • 1. Re: Saving the password of a user in active directory using java
          EJP
          You tried how? With what code?
          • 2. Re: Saving the password of a user in active directory using java
            996011
            DirContext ctx = new InitialDirContext(pr);
                      BasicAttributes entry = new BasicAttributes(true);
                      String entryDN = "cn=CharbelHad,ou=test users,dc=test,dc=dev";
                      Attribute cn = new BasicAttribute("cn", "ChHad");
                      Attribute street = (new BasicAttribute("streetAddress", "Ach"));
                      Attribute loginPreW2k = (new BasicAttribute("sAMAccountName", "ChlHad@test.dev"));
                      Attribute login = (new BasicAttribute("userPrincipalName", "ChlHad@test.dev"));
                      Attribute sn = (new BasicAttribute("sn", "Chl"));
                      Attribute pwd = new BasicAttribute("unicodePwd", "\"Ch@341\"".getBytes("UTF-8"));
            Attribute userAccountControl = new BasicAttribute("userAccountControl", "512");
                      Attribute oc = new BasicAttribute("objectClass");
                      oc.add("top");
                      oc.add("person");
                      oc.add("organizationalPerson");
                      oc.add("user");
                      // build the entry
                      entry.put(cn);
                      entry.put(street);
                      entry.put(sn);
                      entry.put(userAccountControl);
                      entry.put(pwd);
                      entry.put(login);
                      entry.put(loginPreW2k);
                      entry.put(oc);
                      ctx.createSubcontext(entryDN, entry);
            • 3. Re: Saving the password of a user in active directory using java
              EJP
              What's in 'pr'? You need to be using SSL to change password attributes in AD.