[Freeipa-devel] [PATCH 0137] ipalib: Add DateTime parameter

Jan Cholasta jcholast at redhat.com
Fri Apr 25 09:08:43 UTC 2014

On 22.4.2014 13:32, Tomas Babej wrote:
> Thank you for the suggestions. Updated, rebased patch is attached.

This API.txt change from the next patch belongs in this patch:

+capability: datetime_values 2.84

I think you should use the LDAP_GENERALIZED_TIME_FORMAT constant here:

+    accepted_formats = ['%Y%m%d%H%M%SZ',       # generalized time

This is not right:

+        elif isinstance(val, datetime.datetime):
+            return val

To actually decode LDAP generalized time attributes to datetime, you 
need to do this:

          '2.16.840.1.113719.1.301.4.41.1' : DN,  # krbSubTrees
          '2.16.840.1.113719.1.301.4.52.1' : DN,  # krbObjectReferences
          '2.16.840.1.113719.1.301.4.53.1' : DN,  # krbPrincContainerRef
+        ''  : datetime.datetime,

      # In most cases we lookup the syntax from the schema returned by

and this:

                      return val
                  elif target_type is unicode:
                      return val.decode('utf-8')
+                elif target_type is datetime.datetime:
+                    return datetime.datetime.strptime(val, 
                      return target_type(val)
              except Exception, e:

and add code for formatting datetime values to the textui backend.

Jan Cholasta

More information about the Freeipa-devel mailing list