0 Replies Latest reply on Sep 29, 2004 9:51 AM by madadi

    JBOSS+JNDI+LDAP

    madadi Newbie

      Dear All,

      Iam new to JNDI and LDAP, i wrote a program to insert data into LDAP .but iam getting an error in JBOSS.

      ERROR [STDERR] javax.naming.directory.InvalidAttributeIdentifierException: [LDAP: error code 17 - javaSerializedData: attribute type undefined]; remaining name 'uid=madadi5,ou=AllUsers,dc=ds16.e-technik.uni-dortmund,dc=de'

      I want to Create new group called "AllUsers " and i want add data of individual user data in that group . Help needed....

      Code is as follows::::


      String ldapServerName = "localhost";
      String rootdn = "cn=admin,dc=ds16.e-technik.uni-dortmund,dc=de";
      String rootpass = "secret";
      String rootContext = "dc=ds16.e-technik.uni-dortmund,dc=de";


      Properties env = new Properties();

      env.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory" );
      env.put( Context.PROVIDER_URL, "ldap://" + ldapServerName + "/" + rootContext );
      env.put( Context.SECURITY_PRINCIPAL, rootdn );
      env.put( Context.SECURITY_CREDENTIALS, rootpass );

      try {

      // obtain initial directory context using the environment
      DirContext ctx = new InitialDirContext( env );


      System.out.println( "testing1 for ldap entry from registration client " );

      BasicAttributes mandatory = new BasicAttributes(true);

      BasicAttribute objectclass = new BasicAttribute("objectclass");

      BasicAttribute ouSet = new BasicAttribute("ou");

      objectclass.add("inetorgperson");
      objectclass.add("organizationalperson");
      objectclass.add("person");
      objectclass.add("organizationalUnit");
      objectclass.add("top");

      String ou="AllUsers";

      ouSet.add("AllUsers");
      ouSet.add(ou);

      mandatory.put(objectclass);

      System.out.println( "testing3 for ldap entry" );

      BasicAttribute cn = new BasicAttribute("cn");
      cn.add(lname.toString());
      mandatory.put(cn);

      BasicAttribute sn = new BasicAttribute("sn");
      sn.add(fname.toString());
      mandatory.put(sn);

      System.out.println( "testing4 before state ldap entry from registration client " );

      BasicAttribute st = new BasicAttribute("st");
      st.add(state.toString());
      mandatory.put(st);

      BasicAttribute postalAddress = new BasicAttribute("postalAddress");

      postalAddress.add(street.toString() + "," + city.toString());
      mandatory.put(postalAddress);

      System.out.println( "testing5 for ldap entry from registration client " );

      BasicAttribute l = new BasicAttribute("l");
      l.add(country.toString());
      mandatory.put(l);

      BasicAttribute postalCode = new BasicAttribute("postalCode");
      postalCode.add(zipc.toString());
      mandatory.put(postalCode);

      BasicAttribute telephoneNumber = new BasicAttribute("telephoneNumber");
      telephoneNumber.add(phone.toString());
      mandatory.put(telephoneNumber);

      BasicAttribute mail = new BasicAttribute("mail");
      mail.add(email.toString());
      mandatory.put(mail);

      BasicAttribute description = new BasicAttribute("description");
      description.add("USER personal-data");
      mandatory.put(description);


      BasicAttribute userPassword = new BasicAttribute("userPassword");
      userPassword.add(password.toString());
      mandatory.put(userPassword);


      System.out.println( "testing6" );


      ctx.bind("uid="+userid+",ou=AllUsers",mandatory);

      System.out.println( "testing7" );




      } catch ( NameAlreadyBoundException nabe ) {
      System.err.println( "value has already been bound!" );
      }