Пример #1
0
void LdifWriter::writeRecord(const LDAPEntry& le)
{
    std::ostringstream line;

    if ( m_addSeparator )
    {
        m_ldifstream << std::endl;
    } else {
        m_addSeparator = true;
    }

    line << "dn: " << le.getDN();
    this->breakline( line.str(), m_ldifstream );

    const LDAPAttributeList *al = le.getAttributes();
    LDAPAttributeList::const_iterator i = al->begin();
    for ( ; i != al->end(); i++ )
    {
        StringList values = i->getValues();
        StringList::const_iterator j = values.begin();
        for( ; j != values.end(); j++)
        {
            // clear output stream
            line.str("");
            line << i->getName() << ": " << *j;
            this->breakline( line.str(), m_ldifstream );
        }
    }
}
const LDAPAttribute* LDAPAttributeList::getAttributeByName(
	const string& name) const {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPAttribute::getAttributeByName()" << endl);
    DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
            "   name:" << name << endl);
    LDAPAttributeList::const_iterator i;
    for( i = m_attrs.begin(); i != m_attrs.end(); i++){
	const std::string& tmpType = i->getName();
	if(name.size() == tmpType.size()){
	    if(equal(name.begin(), name.end(), tmpType.begin(),
		    nocase_compare)){
		return &(*i);
		DEBUG(LDAP_DEBUG_TRACE,"    found:" << name << endl);
	    }
	}
    }
    return 0;
}