# File lib/ldap/ldif.rb, line 496
    def LDIF.mods_to_ldif( dn, *mods )
      ldif = "dn: %s\nchangetype: modify\n" % dn
      plural = false

      mods.flatten.each do |mod|
        # TODO: Need to dynamically assemble this case statement to add
        # OpenLDAP's increment change type, etc.
        change_type = case mod.mod_op & ~LDAP_MOD_BVALUES
                        when LDAP_MOD_ADD     then 'add'
                        when LDAP_MOD_DELETE  then 'delete'
                        when LDAP_MOD_REPLACE then 'replace'
                      end

        ldif << "-\n" if plural
        ldif << LDIF.to_ldif( change_type, mod.mod_type )
        ldif << LDIF.to_ldif( mod.mod_type, mod.mod_vals )

        plural = true
      end

      LDIF::Mod.new( ldif )
    end