Hello!
First sorry if i'm posting in the wrong place, my question is really about JNDI, but I decided to post here also if anyone knows.
I'm having trouble using bind() to insert a user in ldap. Every time I enter, it goes with the type "default", think like a Java object, when actually i want to enter it as normal ldap user, with a few more fields, etc..
I realized that those users who are already in ldap, listing them is "uid = user1", "uid = user2," and when I insert it becomes "cn = test1", "cn = test2", with fewer fields that other type.
What I would do was to insert a user with those fields that user to "uid = user1" has. I'll post how I'm doing:
If something is wrong, feel free to say! Thanks!
Attribute cn = new BasicAttribute( "cn", "test" ); Attribute gidNumber = new BasicAttribute( "gidNumber", "999" ); Attribute homeDirectory = new BasicAttribute( "homeDirectory", "/home/users/test" );
Attribute javaContainer = new BasicAttribute( "javaContainer" ); javaContainer.add( new BasicAttribute( "cn", "test" ) );
Attribute objectClass = new BasicAttribute( "objectClass" );
objectClass.add( "top" ); objectClass.add( "person" ); objectClass.add( "organizationalPerson" ); objectClass.add( "inetOrgPerson" ); objectClass.add( "posixAccount" ); objectClass.add( "shadowAccount" ); objectClass.add( "sambaSamAccount" ); objectClass.add( "user" );
Attribute sambaSID = new BasicAttribute( "sambaSID", "S-1-5-21-450180999-1854538958-2124921490-61212" ); Attribute sn = new BasicAttribute( "sn", "test" ); Attribute uidNumber = new BasicAttribute( "uidNumber", "4566" ); Attribute userName = new BasicAttribute( "uid", "test" ); Attribute userPassword = new BasicAttribute( "userPassword", "test123" );
Attributes entry = new BasicAttributes();
entry.put( cn ); entry.put( gidNumber ); entry.put( homeDirectory ); entry.put( javaContainer ); entry.put( objectClass ); entry.put( sambaSID ); entry.put( sn ); entry.put( uidNumber ); entry.put( userName ); entry.put( userPassword );
try{ ctx.bind( "cn=test,ou=Users", entry ); } catch( Exception e ){ e.printStackTrace(); }
--On Thursday, October 14, 2010 8:34 AM -0300 Vitor Braga vitor.leitebraga@gmail.com wrote:
Hello!
First sorry if i'm posting in the wrong place, my question is really about JNDI, but I decided to post here also if anyone knows.
I would advise you to use a better API than JNDI, it will make your life a lot easier, and help you avoid a number of known issues with JNDI. You may want to look at http://www.unboundid.com/products/ldapsdk/
--Quanah
--
Quanah Gibson-Mount Principal Software Engineer Zimbra, Inc -------------------- Zimbra :: the leader in open source messaging and collaboration
openldap-technical@openldap.org