commit aa4e021cfd1249780f42bed7118e8697c06b21c2
Author: Marc Dequènes (Duck) <Duck@DuckCorp.org>
Date:   Mon Oct 26 23:49:20 2009 +0100

    [evol] replace DNs with recognized objects in show command (if not in debug mode)

diff --git a/TODO b/TODO
index 36dd089..5c665fa 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
 - ensure removing an aspect also remove reverse-depends
-- replace DNs with recognized objects in show command (if not in debug mode)
 - improve configuration:
   * allow global relations to share them among objects ???
 - select parent at creation with :parent if present, or use
diff --git a/bin/shadowwalker b/bin/shadowwalker
index 2ad034f..7078821 100755
--- a/bin/shadowwalker
+++ b/bin/shadowwalker
@@ -269,6 +269,10 @@ class ShowCommand < Command
 
         result = field_data[file_no]
         result_is_binary = attr_info.binary?
+
+        unless result_is_binary or $program_options[:debug]
+          result = LdapShadows::Manipulation.interpret_field_value($shadow, attr_info.syntax.to_param, result)
+        end
       end
 
       if args.empty?
diff --git a/lib/ldap_shadows/display_helper.rb b/lib/ldap_shadows/display_helper.rb
index 51dad27..9869f7f 100644
--- a/lib/ldap_shadows/display_helper.rb
+++ b/lib/ldap_shadows/display_helper.rb
@@ -17,6 +17,7 @@
 #++
 
 require 'active_support'
+require 'ldap_shadows/manipulation_helper'
 
 
 module LdapShadows
@@ -48,7 +49,7 @@ module LdapShadows
   end
 
   module Display
-    def self.display_fields(attr_data, options = {})
+    def self.display_fields(shadow, attr_data, options = {})
       attr_data.each_pair do |key, val|
         next if val[:expert] and not options[:expert]
         next if val[:admin] and not options[:admin]
@@ -60,7 +61,9 @@ module LdapShadows
         if val[:binary] and options[:skip_binary]
           str += " -> #{val[:value].size} file(s) available"
         else
-          str += ": " + (val[:multiple] ? val[:value].sort.collect{|v| v.to_s }.join(", ") : val[:value].to_s)
+          str += ": " + (val[:multiple] ?
+            val[:value].sort.collect{|v| LdapShadows::Manipulation.interpret_field_value(shadow, val[:syntax], v).to_s }.join(", ") :
+            LdapShadows::Manipulation.interpret_field_value(shadow, val[:syntax], val[:value]).to_s)
         end
 
         puts str
@@ -101,13 +104,13 @@ module LdapShadows
       else
         obj_info, obj_aspects = item.organized_data
 
-        display_fields(obj_info, options)
+        display_fields(item.class.shadow, obj_info, options)
 
         obj_aspects.each_pair do |aspect_name, aspect_data|
           name = Translator.translate_aspect_name(aspect_name)
           name += " [#{aspect_name}]" if options[:handles]
           puts "--- #{name} ---"
-          display_fields(aspect_data, options)
+          display_fields(item.class.shadow, aspect_data, options)
         end
 
         if options[:show_family_members]
diff --git a/lib/ldap_shadows/elements/object.rb b/lib/ldap_shadows/elements/object.rb
index 39a2159..6639e09 100755
--- a/lib/ldap_shadows/elements/object.rb
+++ b/lib/ldap_shadows/elements/object.rb
@@ -549,12 +549,14 @@ module Elements
     def fetch_attributes_data(attr_list, expert_attributes, admin_attributes)
       attr_data = self.attributes.collect do |key, val|
         if attr_list.include?(key)
+          attr_info = ActiveLdap::Base.schema.attribute(key)
           [key, {
+             :syntax => attr_info.syntax.to_param,
              :value => val,
              :multiple => (val.is_a?(Array) ? val.size : 1),
              :expert => expert_attributes.include?(key),
              :admin => admin_attributes.include?(key),
-             :binary => ActiveLdap::Base.schema.attribute(key).binary?
+             :binary => attr_info.binary?
            }]
         else
           nil
@@ -588,6 +590,7 @@ module Elements
         else
           rel_key = "rel:" + rel
           [rel_key, {
+             :syntax => nil,
              :value => value,
              :multiple => multiple,
              :expert => expert_attributes.include?(rel_key),
diff --git a/lib/ldap_shadows/manipulation_helper.rb b/lib/ldap_shadows/manipulation_helper.rb
index 08b7795..7bc704b 100644
--- a/lib/ldap_shadows/manipulation_helper.rb
+++ b/lib/ldap_shadows/manipulation_helper.rb
@@ -95,14 +95,30 @@ module LdapShadows
       nil
     end
 
-    def self.raw_item_info(shadow, raw_item)
-      obj_hdl = self.find_raw_item_object(shadow, raw_item)
-      if obj_hdl
-        obj_klass = shadow.get_object(obj_hdl)
-        item = obj_klass.new(raw_item.dn)
-        {:name => item.full_handle, :item => item, :object => obj_klass}
+    def self.raw_item_info(shadow, raw_item, dn = nil)
+      if raw_item
+        obj_hdl = self.find_raw_item_object(shadow, raw_item)
+        if obj_hdl
+          obj_klass = shadow.get_object(obj_hdl)
+          item = obj_klass.new(raw_item.dn)
+          return {:name => item.full_handle, :item => item, :object => obj_klass}
+        end
+
+        item_fake_hdl = raw_item.dn
+      else
+        item_fake_hdl = dn || "???"
+      end
+
+      {:name => "unknown/#{item_fake_hdl}"}
+    end
+
+    def self.interpret_field_value(shadow, syntax, val)
+      case syntax
+      when "1.3.6.1.4.1.1466.115.121.1.12"
+        raw_item = ActiveLdap::Base.find(:first, :base => val.to_s, :scope => :base)
+        LdapShadows::Manipulation.raw_item_info($shadow, raw_item, val.to_s)[:name]
       else
-        {:name => "unknown/#{raw_item.dn}"}
+        val
       end
     end
 
