1 Reply Latest reply: Feb 19, 2013 5:15 AM by 972794 RSS

    LDAP & active Directory, SSL connection problem

    972794
      Hi,
      I am trying to connect LDAP(Active directory). I have successfully connected to that. I am facing problems in changing the password. I know that if I want to change the domain password, I should have the SSL connection. I am getting struck here. Here is my code :

      public void tabOut(ValueChangeEvent valueChangeEvent) {
      DirContext ldapContext;
      String baseName = "cn=users,DC=activedirectory,DC=ispl,DC=com";
      String serverIP = "apopsdc";
      String modelUsername = "template";
      try {

      Hashtable env = new Hashtable(11);
      env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
      env.put(Context.SECURITY_AUTHENTICATION, "Simple");
      //it can be <domain\\userid> something that you use for windows login
      //it can also be
      env.put(Context.SECURITY_PRINCIPAL, "*****");
      env.put(Context.SECURITY_PROTOCOL, "ssl");


      env.put(Context.SECURITY_CREDENTIALS, "*****");
      //in following property we specify ldap protocol and connection url.
      //generally the port is 389
      env.put(Context.PROVIDER_URL, "ldap://apopsdc.ispl.com:389");

      ldapContext = new InitialDirContext(env);
      DirContext ctx = (DirContext)ldapContext;
      System.out.println("Context Sucessfully Initialized");
      Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
      System.out.println("works");
      System.setProperty("javax.net.ssl.trustStore", "C:\\Program Files\\Java\\jdk1.6.0_26\\sample\\jmx\\jmx-scandir");
      System.out.println("successs !!");

      ModificationItem[] mods = new ModificationItem[1];
      mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("userpassword" ,"Aptuit*1" ));
      System.out.println("step 3");
      ctx.modifyAttributes(baseName, mods);
      System.out.println("step 4");
      System.out.println("success base");
      ctx.close();


      } catch (Exception e) {
      System.out.println(" bind error: " + e);
      e.printStackTrace();
      System.exit(-1);
      }

      I am getting error in this line : "ctx.modifyAttributes(baseName, mods);"

      Error : bind error: javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001CD, problem 2001 (NO_OBJECT), data 0, best match of:
           'DC=ispl,DC=com'

      What is the solution for this?