return null;
}
try
{
Attribute serverAttribute = new DefaultAttribute( attributeType );
for ( NamingEnumeration<?> values = attribute.getAll(); values.hasMoreElements(); )
{
Object value = values.nextElement();
int nbAdded = 0;
if ( value == null )
{
continue;
}
if ( serverAttribute.isHumanReadable() )
{
if ( value instanceof String )
{
nbAdded = serverAttribute.add( ( String ) value );
}
else if ( value instanceof byte[] )
{
nbAdded = serverAttribute.add( Strings.utf8ToString( ( byte[] ) value ) );
}
else
{
throw new LdapInvalidAttributeTypeException();
}
}
else
{
if ( value instanceof String )
{
nbAdded = serverAttribute.add( Strings.getBytesUtf8( ( String ) value ) );
}
else if ( value instanceof byte[] )
{
nbAdded = serverAttribute.add( ( byte[] ) value );
}
else
{
throw new LdapInvalidAttributeTypeException();
}