Record objects are embodiments of LDAP operations. They possess a DN, a change type (LDAP_MOD_ADD, LDAP_MOD_DELETE or LDAP_MOD_REPLACE [any of which can be logically AND'ed with LDAP_MOD_BVALUES]), a hash of attributes and value arrays, a hash of modification operations (useful only when the change type is LDAP_MOD_REPLACE) and an array of LDAP controls.
The Record class's primary use is as a transitional medium for LDIF operations parsed by the LDAP::LDIF module. You are unlikely to want to use it in application code.
Remove common operational attributes from a Record object. This is useful if you have Record objects formed from LDIF data that contained operational attributes. Using LDAP::Record#send to send such an object to an LDAP server is likely to meet with an exception unless the data is first cleaned.
In addition, attributes with duplicate values are pruned, as this can also result in an exception.
# File lib/ldap/ldif.rb, line 71 def clean # TODO: These operational attributes are those commonly used by # OpenLDAP 2.2. Others should probably be supported. # ] creatorsname createtimestamp modifiersname modifytimestamp entrycsn entryuuid structuralobjectclass ].each do |attr| @attrs.delete( attr ) end # Clean out duplicate attribute values. @attrs.each_key { |k| @attrs[k].uniq! } self end
Send the operation embodied in the Record object to the LDAP::Conn object specified in conn.
# File lib/ldap/ldif.rb, line 38 def send( conn ) if @change_type == :MODRDN # TODO: How do we deal with 'newsuperior'? # The LDAP API's ldap_modrdn2_s() function doesn't seem to use it. return conn.modrdn( @dn, @attrs['newrdn'], @attrs['deleteoldrdn'] ) end # Mask out the LDAP_MOD_BVALUES bit, as it's irrelevant here. case @change_type & ~LDAP_MOD_BVALUES when LDAP_MOD_ADD @controls == [] ? conn.add( @dn, @attrs ) : conn.add_ext( @dn, @attrs, @controls, [] ) when LDAP_MOD_DELETE @controls == [] ? conn.delete( @dn ) : conn.delete_ext( @dn, @controls, [] ) when LDAP_MOD_REPLACE @controls == [] ? conn.modify( @dn, @mods ) : conn.modify_ext( @dn, @mods, @controls, [] ) end self end
Generated with the Darkfish Rdoc Generator 2.