Java Code Examples for org.apache.directory.api.ldap.model.entry.Attribute#getId()
The following examples show how to use
org.apache.directory.api.ldap.model.entry.Attribute#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaAwareEntryTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test method for Iterator() */ @Test public void testIterator() throws LdapException { Entry entry = createEntry(); Iterator<Attribute> iterator = entry.iterator(); assertTrue( iterator.hasNext() ); Set<String> expectedIds = new HashSet<String>(); expectedIds.add( "objectclass" ); expectedIds.add( "cn" ); expectedIds.add( "sn" ); expectedIds.add( "userpassword" ); while ( iterator.hasNext() ) { Attribute attribute = iterator.next(); String id = attribute.getId(); assertTrue( expectedIds.contains( id ) ); expectedIds.remove( id ); } assertEquals( 0, expectedIds.size() ); }
Example 2
Source File: ApacheLdapProviderImpl.java From ldapchai with GNU Lesser General Public License v2.1 | 5 votes |
public Map<String, String> readStringAttributes( final String entryDN, final Set<String> attributes ) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException { activityPreCheck(); getInputValidator().readStringAttributes( entryDN, attributes ); try { final EntryCursor entries = connection.search( entryDN, ChaiConstant.FILTER_OBJECTCLASS_ANY, org.apache.directory.api.ldap.model.message.SearchScope.OBJECT, attributes.toArray( new String[attributes.size()] ) ); final Entry entry = entries.iterator().next(); final Collection<Attribute> attrs = entry.getAttributes(); final Map<String, String> returnMap = new LinkedHashMap<>(); for ( final Attribute attr : attrs ) { final String name = attr.getId(); final String value = attr.getString(); returnMap.put( name, value ); } return returnMap; } catch ( LdapException e ) { throw ChaiOperationException.forErrorMessage( e.getMessage() ); } }