You could also try to use our Apache LDAP API instead of JNDI. => http://directory.apache.org/api/downloads.html
And, in code, what does 'ctls' look like? Can you show us the definition ? Regards, Piere-Arnaud On 11 sept. 2012, at 16:35, Merve Temizer <[email protected]> wrote: > According to page > > http://docs.oracle.com/javase/jndi/tutorial/basics/directory/getattrs.html > > I have tried > > for (NamingEnumeration ae = sr.getAttributes().getAll(); ae.hasMore();) { > Attribute attr = > (Attribute)ae.next(); > System.out.println("attribute: " + > attr.getID()); > /* Print each value */ > for (NamingEnumeration e = > attr.getAll(); e.hasMore(); > System.out.println("value: " + > e.next())); > } > Output: > > attribute: dc > value: is > attribute: objectClass > value: extensibleObject > value: organizationalUnit > value: top > > Can not see ou attribute. Sorry for simple questions but i did what tutorial > tells. > > > 2012/9/11 Emmanuel Lécharny <[email protected]> > Le 9/11/12 2:54 PM, Merve Temizer a écrit : > > Hello, > > I have some objectClasses and dc and ou attributes and their values, in an > entry in LDAP. > I try to read ou attribute but i cant get it with below code. > I can get dc value correctly. > I know i must control if it is null, but why might "ou" be null despite of > taking place in LDAP. > > NamingEnumeration answer = ctx.search(searchBaseDn, filter, ctls); > try > { > while (answer.hasMore()) > { > SearchResult sr = (SearchResult) answer.next(); > OrganizationPojo organizationPojo = new OrganizationPojo(); > organizationPojo.setOrgDc((String)sr.getAttributes().get("dc").get()); > organizationPojo.setOrgOu((String)sr.getAttributes().get("ou").get()); > > http://docs.oracle.com/javase/jndi/tutorial/ > > -- > Regards, > Cordialement, > Emmanuel Lécharny > www.iktek.com > >
