Skip to content
Snippets Groups Projects
LDAPEntry.h 2.93 KiB
Newer Older
/*
 * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */


#ifndef LDAP_ENTRY_H
#define LDAP_ENTRY_H
#include <ldap.h>

Ralf Haferkamp's avatar
Ralf Haferkamp committed
class LDAPAsynConnection;

Ralf Haferkamp's avatar
Ralf Haferkamp committed
/**
 * This class is used to store every kind of LDAP Entry.
 */
Ralf Haferkamp's avatar
Ralf Haferkamp committed
        /**
         * Copy-constructor
         */
        LDAPEntry(const LDAPEntry& entry);
Ralf Haferkamp's avatar
Ralf Haferkamp committed

        /**
         * Constructs a new entry (also used as standard constructor).
         *
         * @param dn    The Distinguished Name for the new entry.
         * @param attrs The attributes for the new entry.
         */
        LDAPEntry(const std::string& dn=std::string(), 
                const LDAPAttributeList *attrs=new LDAPAttributeList());
Ralf Haferkamp's avatar
Ralf Haferkamp committed

        /**
         * Used internally only.
         *
         * The constructor is used internally to create a LDAPEntry from
         * the C-API's data structurs.
         */ 
        LDAPEntry(const LDAPAsynConnection *ld, LDAPMessage *msg);
Ralf Haferkamp's avatar
Ralf Haferkamp committed

        /**
         * Destructor
         */
Ralf Haferkamp's avatar
Ralf Haferkamp committed
        
        /**
         * Sets the DN-attribute.
         * @param dn: The new DN for the entry.
         */
        void setDN(const std::string& dn);
Ralf Haferkamp's avatar
Ralf Haferkamp committed

        /**
         * Sets the attributes of the entry.
         * @param attr: A pointer to a std::list of the new attributes.
Ralf Haferkamp's avatar
Ralf Haferkamp committed
         */
        void setAttributes(LDAPAttributeList *attrs);

	/**
	 * Get an Attribute by its AttributeType (simple wrapper around
         * LDAPAttributeList::getAttributeByName() )
	 * @param name The name of the Attribute to look for
	 * @return a pointer to the LDAPAttribute with the AttributeType 
	 *	"name" or 0, if there is no Attribute of that Type
	 */
	const LDAPAttribute* getAttributeByName(const std::string& name) const;

        /**
         * Adds one Attribute to the List of Attributes (simple wrapper around
         * LDAPAttributeList::addAttribute() ).
         * @param attr The attribute to add to the list.
         */
        void addAttribute(const LDAPAttribute& attr);

        /**
         * Replace an Attribute in the List of Attributes (simple wrapper
         * around LDAPAttributeList::replaceAttribute() ).
         * @param attr The attribute to add to the list.
         */
        void replaceAttribute(const LDAPAttribute& attr);
Ralf Haferkamp's avatar
Ralf Haferkamp committed

        /**
         * @returns The current DN of the entry.
         */
        const std::string& getDN() const ;
Ralf Haferkamp's avatar
Ralf Haferkamp committed

        /**
         * @returns A const pointer to the attributes of the entry.  
         */
        const LDAPAttributeList* getAttributes() const;
Ralf Haferkamp's avatar
Ralf Haferkamp committed

        /**
         * This method can be used to dump the data of a LDAPResult-Object.
         * It is only useful for debugging purposes at the moment
         */
        friend std::ostream& operator << (std::ostream& s, const LDAPEntry& le);
        LDAPAttributeList *m_attrs;
        std::string m_dn;