// $OpenLDAP$
/*
- * Copyright 2008, OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2008-2013 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
LDAPEntry LdifReader::getEntryRecord()
{
+ std::list<stringpair>::const_iterator i = m_currentRecord.begin();
if ( m_curRecType != LDAPMsg::SEARCH_ENTRY )
{
- // Error
+ throw( std::runtime_error( "The LDIF record: '" + i->second +
+ "' is not a valid LDAP Entry" ));
}
- std::list<stringpair>::const_iterator i = m_currentRecord.begin();
LDAPEntry resEntry(i->second);
i++;
LDAPAttribute curAttr(i->first);
}
else
{
- if ( curAl->getAttributeByName( i->first ) )
+ const LDAPAttribute* existing = curAl->getAttributeByName( i->first );
+ if ( existing )
{
- // Attribute exists already -> Syntax Error
- std::ostringstream err;
- err << "Line " << this->m_lineNumber
- << ": Attribute \"" << i->first
- << "\" specified multiple times.";
- throw( std::runtime_error(err.str()) );
+ // Attribute exists already (handle gracefully)
+ curAl->addAttribute( curAttr );
+ curAttr = LDAPAttribute( *existing );
+ curAttr.addValue(i->second);
+ curAl->delAttribute( i->first );
}
else
{