[Freeipa-devel] [PATCH] unicode fixes for web gui

Kevin McCarthy kmccarth at redhat.com
Fri Aug 17 22:30:24 UTC 2007


This properly utf-8 encodes unicode strings into regular strings so they
make it into ldap.  We're not decoding them yet, but this can be done if
necessary.

Also fixes a stupid bug for updating cn.

-Kevin


-------------- next part --------------
# HG changeset patch
# User Kevin McCarthy <kmccarth at redhat.com>
# Date 1187389925 25200
# Node ID b92cec02be1299dfc9f36358820d221420be4352
# Parent  b4b63f510c5f66dce8f91002928009bd8d83c5dd
change strings to be encoded using value.encode("utf-8").
fix update to set 'cn' instead of 'sn'.
remove str() in funcs.add_user().

diff -r b4b63f510c5f -r b92cec02be12 ipa-server/ipa-gui/ipagui/controllers.py
--- a/ipa-server/ipa-gui/ipagui/controllers.py	Fri Aug 17 14:27:54 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/controllers.py	Fri Aug 17 15:32:05 2007 -0700
@@ -49,7 +49,7 @@ def set_ldap_value(hash, key, value):
     """Converts unicode strings to normal strings
        (because LDAP is choking on unicode strings"""
     if value != None:
-        value = str(value)
+        value = value.encode('utf-8')
     hash[key] = value
 
 
@@ -137,7 +137,7 @@ class Root(controllers.RootController):
             #
             # this is a hack until we decide on the policy for names/cn/sn/givenName
             #
-            set_ldap_value(new_user, 'sn', 
+            set_ldap_value(new_user, 'cn', 
                            "%s %s" % (kw.get('givenname'), kw.get('sn')))
 
             orig_user = to_ldap_hash(orig_user)
diff -r b4b63f510c5f -r b92cec02be12 ipa-server/xmlrpc-server/funcs.py
--- a/ipa-server/xmlrpc-server/funcs.py	Fri Aug 17 14:27:54 2007 -0700
+++ b/ipa-server/xmlrpc-server/funcs.py	Fri Aug 17 15:32:05 2007 -0700
@@ -197,7 +197,7 @@ class IPAServer:
             user = user[0]
 
         dn="uid=%s,%s,%s" % (user['uid'], user_container,self.basedn)
-        entry = ipaserver.ipaldap.Entry(str(dn))
+        entry = ipaserver.ipaldap.Entry(dn)
 
         # some required objectclasses
         entry.setValues('objectClass', 'top', 'posixAccount', 'shadowAccount', 'account', 'person', 'inetOrgPerson', 'organizationalPerson', 'krbPrincipalAux', 'krbTicketPolicyAux')
@@ -214,7 +214,7 @@ class IPAServer:
     
         # fill in our new entry with everything sent by the user
         for u in user:
-            entry.setValues(str(u), str(user[u]))
+            entry.setValues(u, user[u])
 
         if opts:
             self.set_principal(opts['remoteuser'])
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2228 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20070817/7129be3f/attachment.bin>


More information about the Freeipa-devel mailing list